Changeset 8c45eea in git


Ignore:
Timestamp:
26/07/10 10:20:34 (9 years ago)
Author:
Olly Betts <olly@…>
Branches:
add-show-splays, line_contents, master, stereo, svn/github/master, svn/origin/master, svn/tags/1.1.14, svn/tags/1.1.15, svn/tags/1.1.16, svn/tags/1.2.0, svn/tags/1.2.1, svn/tags/1.2.2, svn/tags/1.2.3, svn/tags/1.2.4, svn/tags/1.2.5, svn/trunk, travis-osx
Children:
7e5d688
Parents:
39aa1a0
Message:

configure.in,src/img.c,src/useful.c,src/useful.h: Use AC_TYPE_INT16_T
and AC_TYPE_INT32_T instead of home-brew equivalents.

git-svn-id: file:///home/survex-svn/survex/trunk@3499 4b37db11-9a0c-4f06-9ece-9ab7cdaee568

Files:
5 edited

Legend:

Unmodified
Added
Removed
  • ChangeLog

    r39aa1a0 r8c45eea  
     1Mon Jul 26 09:19:19 GMT 2010  Olly Betts <olly@survex.com>
     2
     3        * configure.in,src/img.c,src/useful.c,src/useful.h: Use AC_TYPE_INT16_T
     4          and AC_TYPE_INT32_T instead of home-brew equivalents.
     5
    16Mon Jul 26 08:40:43 GMT 2010  Olly Betts <olly@survex.com>
    27
  • configure.in

    r39aa1a0 r8c45eea  
    228228], , AC_DEFINE(CLOCKS_PER_SEC, 1000000, [For old systems which don't define it themselves]))
    229229
    230 dnl Look for a signed 32 bit integer type
    231 AC_MSG_CHECKING(for 32 bit integer type)
    232 AC_TRY_COMPILE(,[switch (0) { case (sizeof(int)==4): case 0: break; }],
    233 INT32_T=int,
    234 AC_TRY_COMPILE(,[switch (0) { case (sizeof(long)==4): case 0: break; }],
    235 INT32_T=long,
    236 AC_MSG_ERROR(not found)
    237 )
    238 )
    239 AC_MSG_RESULT($INT32_T)
    240 AC_DEFINE_UNQUOTED(INT32_T,$INT32_T,[signed 32 bit integer type])
    241 
    242 dnl Look for a signed 16 bit integer type
    243 AC_MSG_CHECKING(for 16 bit integer type)
    244 AC_TRY_COMPILE(,[switch (0) { case (sizeof(short)==2): case 0: break; }],
    245 INT16_T=short,
    246 AC_TRY_COMPILE(,[switch (0) { case (sizeof(int)==2): case 0: break; }],
    247 INT16_T=int,
    248 AC_MSG_ERROR(not found)
    249 )
    250 )
    251 AC_MSG_RESULT($INT16_T)
    252 AC_DEFINE_UNQUOTED(INT16_T,$INT16_T,[signed 16 bit integer type])
     230dnl Check for 16-bit and 32-bit integer types.
     231AC_TYPE_INT16_T
     232AC_TYPE_INT32_T
    253233
    254234dnl Checks for library functions.
  • src/img.c

    r39aa1a0 r8c45eea  
    4141# define TIMENA msg(/*Date and time not available.*/108)
    4242# define TIMEFMT msg(/*%a,%Y.%m.%d %H:%M:%S %Z*/107)
     43# define INT32_T int32_t
    4344#else
    4445# define INT32_T int
  • src/useful.c

    r39aa1a0 r8c45eea  
    2727
    2828/* used by macro versions of useful_get<nn> functions */
    29 INT16_T useful_w16;
    30 INT32_T useful_w32;
     29int16_t useful_w16;
     30int32_t useful_w32;
    3131
    3232#if 0 /* these functions aren't needed - macros do the job */
    3333/* the numbers in the file are little endian, so use fread/fwrite */
    3434extern void Far
    35 useful_put16(INT16_T w, FILE *fh)
     35useful_put16(int16_t w, FILE *fh)
    3636{
    3737   fwrite(&w, 2, 1, fh);
     
    4040#undef useful_put32
    4141extern void Far
    42 useful_put32(INT32_T w, FILE *fh)
     42useful_put32(int32_t w, FILE *fh)
    4343{
    4444   fwrite(&w, 4, 1, fh);
     
    4646
    4747#undef useful_get16
    48 extern INT16_T Far
     48extern int16_t Far
    4949useful_get16(FILE *fh)
    5050{
    51    INT16_T w;
     51   int16_t w;
    5252   fread(&w, 2, 1, fh);
    5353   return w;
     
    5555
    5656#undef useful_put32
    57 extern INT32_T Far
     57extern int32_t Far
    5858useful_get32(FILE *fh)
    5959{
    60    INT32_T w;
     60   int32_t w;
    6161   fread(&w, 4, 1, fh);
    6262   return w;
     
    6767
    6868extern void Far
    69 useful_put16(INT16_T w, FILE *fh)
     69useful_put16(int16_t w, FILE *fh)
    7070{
    7171   putc((char)(w), fh);
     
    7474
    7575extern void Far
    76 useful_put32(INT32_T w, FILE *fh)
     76useful_put32(int32_t w, FILE *fh)
    7777{
    7878   putc((char)(w), fh);
     
    8282}
    8383
    84 extern INT16_T Far
     84extern int16_t Far
    8585useful_get16(FILE *fh)
    8686{
    87    INT16_T w;
     87   int16_t w;
    8888   w = getc(fh);
    89    w |= (INT16_T)(getc(fh) << 8l);
     89   w |= (int16_t)(getc(fh) << 8l);
    9090   return w;
    9191}
    9292
    93 extern INT32_T Far
     93extern int32_t Far
    9494useful_get32(FILE *fh)
    9595{
    96    INT32_T w;
     96   int32_t w;
    9797   w = getc(fh);
    98    w |= (INT32_T)(getc(fh) << 8l);
    99    w |= (INT32_T)(getc(fh) << 16l);
    100    w |= (INT32_T)(getc(fh) << 24l);
     98   w |= (int32_t)(getc(fh) << 8l);
     99   w |= (int32_t)(getc(fh) << 16l);
     100   w |= (int32_t)(getc(fh) << 24l);
    101101   return w;
    102102}
  • src/useful.h

    r39aa1a0 r8c45eea  
    2323
    2424#include <config.h>
     25
     26#if HAVE_STDINT_H
     27# include <stdint.h>
     28#endif
    2529
    2630#include <stdlib.h> /* for Borland C which #defines max() & min() there */
     
    114118
    115119#ifndef WORDS_BIGENDIAN
    116 extern INT16_T useful_w16;
    117 extern INT32_T useful_w32;
     120extern int16_t useful_w16;
     121extern int32_t useful_w32;
    118122
    119 # define put16(W, FH) BLK(INT16_T w = (W); fwrite(&w, 2, 1, (FH));)
    120 # define put32(W, FH) BLK(INT32_T w = (W); fwrite(&w, 4, 1, (FH));)
     123# define put16(W, FH) BLK(int16_t w = (W); fwrite(&w, 2, 1, (FH));)
     124# define put32(W, FH) BLK(int32_t w = (W); fwrite(&w, 4, 1, (FH));)
    121125# define get16(FH) (fread(&useful_w16, 2, 1, (FH)), useful_w16)
    122126# define get32(FH) (fread(&useful_w32, 4, 1, (FH)), useful_w32)
    123127#else
    124128/* FIXME: why are these "Far"? */
    125 void Far useful_put16(INT16_T, FILE *);
    126 void Far useful_put32(INT32_T, FILE *);
    127 INT16_T Far useful_get16(FILE *);
    128 INT32_T Far useful_get32(FILE *);
     129void Far useful_put16(int16_t, FILE *);
     130void Far useful_put32(int32_t, FILE *);
     131int16_t Far useful_get16(FILE *);
     132int32_t Far useful_get32(FILE *);
    129133
    130134# define put16(W, FH) useful_put16(W, FH)
Note: See TracChangeset for help on using the changeset viewer.