[dhcp-agent-commits] dhcp-agent Makefile.am,1.4,1.5 configure.ac,1.5,1.6 config.h.in,1.4,1.5 acinclu
Status: Alpha
Brought to you by:
actmodern
From: <act...@us...> - 2003-05-18 02:58:28
|
Update of /cvsroot/dhcp-agent/dhcp-agent In directory sc8-pr-cvs1:/tmp/cvs-serv13305 Modified Files: Makefile.am configure.ac config.h.in acinclude.m4 Log Message: better portability for C99 inttypes macros Index: Makefile.am =================================================================== RCS file: /cvsroot/dhcp-agent/dhcp-agent/Makefile.am,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** Makefile.am 11 May 2003 17:01:45 -0000 1.4 --- Makefile.am 18 May 2003 02:58:25 -0000 1.5 *************** *** 7,8 **** --- 7,9 ---- SUBDIRS = src man tests conf EXTRA_DIST = CAVEATS LICENSE README THANKS TODO UPGRADING + CLEANFILES = stdint_marcos.h Index: configure.ac =================================================================== RCS file: /cvsroot/dhcp-agent/dhcp-agent/configure.ac,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** configure.ac 15 May 2003 05:08:13 -0000 1.5 --- configure.ac 18 May 2003 02:58:25 -0000 1.6 *************** *** 50,57 **** AC_WF_TRY_PRI_MACROS ! if test -z "$have_primacros"; then ! echo -n "attempting to generate stdint conversion macros..." ! AC_WF_GET_PRI_MACROS ! AC_DEFINE(HAVE_PRIMACROS_H, 1, [ generated our own primacros ]) echo " done!" fi --- 50,76 ---- AC_WF_TRY_PRI_MACROS ! if test "x$have_primacros" = "x"; then ! ! dnl this ought to work -- i think :-) ! ! echo > stdint_marcos.h ! ! echo "#define PRIi8 \"i\"" >> stdint_marcos.h ! echo "#define PRIi16 \"i\"" >> stdint_marcos.h ! echo "#define PRIi32 \"i\"" >> stdint_marcos.h ! ! echo "#define PRIu8 \"u\"" >> stdint_marcos.h ! echo "#define PRIu16 \"u\"" >> stdint_marcos.h ! echo "#define PRIu32 \"u\"" >> stdint_marcos.h ! ! echo "#define SCNi8 \"hhi\"" >> stdint_marcos.h ! echo "#define SCNi16 \"hi\"" >> stdint_marcos.h ! echo "#define SCNi32 \"i\"" >> stdint_marcos.h ! ! echo "#define SCNu8 \"hhu\"" >> stdint_marcos.h ! echo "#define SCNu16 \"hu\"" >> stdint_marcos.h ! echo "#define SCNu32 \"u\"" >> stdint_marcos.h ! ! AC_DEFINE(HAVE_STDINT_MARCOS_H, 1, [ generated our own primacros ]) echo " done!" fi Index: config.h.in =================================================================== RCS file: /cvsroot/dhcp-agent/dhcp-agent/config.h.in,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** config.h.in 15 May 2003 05:08:13 -0000 1.4 --- config.h.in 18 May 2003 02:58:25 -0000 1.5 *************** *** 31,37 **** #undef HAVE_MEMORY_H - /* generated our own primacros */ - #undef HAVE_PRIMACROS_H - /* have __progname var */ #undef HAVE_PROGNAME --- 31,34 ---- *************** *** 51,54 **** --- 48,54 ---- /* Define to 1 if you have the <stdint.h> header file. */ #undef HAVE_STDINT_H + + /* generated our own primacros */ + #undef HAVE_STDINT_MARCOS_H /* Define to 1 if you have the <stdlib.h> header file. */ Index: acinclude.m4 =================================================================== RCS file: /cvsroot/dhcp-agent/dhcp-agent/acinclude.m4,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** acinclude.m4 29 Oct 2002 17:11:03 -0000 1.1.1.1 --- acinclude.m4 18 May 2003 02:58:25 -0000 1.2 *************** *** 45,157 **** #include <stdlib.h> #include <inttypes.h> ! ], [uint32_t t=1; printf("%"PRIu32, t)], [AC_MSG_RESULT(found) have_primacros="yes"], AC_MSG_RESULT(not found))]) - - - AC_DEFUN(AC_WF_GET_PRI_MACROS, - [AC_TRY_RUN([ - /* lack of C99 support caused me to do this. - * this code is probably hard to modify so don't - * instead contact me for help. - * - * I'm placing this in the public domain. Use it for - * your project if you want. - * - * Thamer Alharbash tm...@wh... */ - - #include <stdio.h> - #include <stdlib.h> - - #include <sys/types.h> - #include <inttypes.h> - #include <errno.h> - #include <string.h> - - #define TABLE_SIZE 4 - - /* substitutions as we know them. */ - - #define SUB_UNSIGNED_LONG "lu" - #define SUB_UNSIGNED_SHORT "hu" - #define SUB_LONG "li" - #define SUB_SHORT "hi" - #define SUB_INT "d" - #define SUB_UNSIGNED_INT "du" - #define SUB_CHAR "d" /* same -- we're assuming int is always bigger than char */ - #define SUB_UNSIGNED_CHAR "du" /* which is an OK assumption (or is it?). */ - - - - - static void output_type_substitution(FILE *fp, - char *sub_string, - size_t size, - char **sub_table, - size_t *size_table) - { - int i; - - for(i = 0;i < TABLE_SIZE; i++) { - - if(size_table[i] == size) { - fprintf(fp, "#define %s \\"%s\\"\n", sub_string, sub_table[i]); - break; - } - } - - if(i == TABLE_SIZE) { - /* blah. we couldn't find a suitable type. Issue warning and use largest size.*/ - - fprintf(stderr, "* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *\n"); - fprintf(stderr, "* Warning! I couldn't find a suitable type that's size for a type.\n"); - fprintf(stderr, "* I'm going to go and use the largest I can and hope things work! *\n"); - fprintf(stderr, "* Please do report this bug to tm...@wh... *\n"); - fprintf(stderr, "* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *\n"); - - fprintf(fp, "#define %s \\"%s\\"\n", sub_string, sub_table[0]); - } - - return; - } - - int main(int argc, char *argv[]) - { - FILE *fp; - char *signed_sub_table[] = { SUB_LONG, SUB_SHORT, SUB_INT, SUB_CHAR }; - char *unsigned_sub_table[] = { SUB_UNSIGNED_LONG, SUB_UNSIGNED_SHORT, SUB_UNSIGNED_INT, - SUB_UNSIGNED_CHAR }; - size_t signed_size_table[] = { sizeof(long), sizeof(short), sizeof(int), - sizeof(char) }; - size_t unsigned_size_table[] = { sizeof(unsigned long), sizeof(unsigned short), - sizeof(unsigned int), sizeof(unsigned char) }; - - fp = fopen("primacros.h", "w"); - if(fp == NULL) { - perror("fopen"); - exit(1); - } - - fprintf(fp, "/* Automatically generated PRI macros. *\n"); - fprintf(fp, " * This is because you don't have them.*/\n"); - - output_type_substitution(fp, "PRIu32", sizeof(uint32_t), - unsigned_sub_table, unsigned_size_table); - - output_type_substitution(fp, "PRIi32", sizeof(int32_t), - signed_sub_table, signed_size_table); - - - output_type_substitution(fp, "PRIu16", sizeof(uint16_t), - unsigned_sub_table, unsigned_size_table); - - output_type_substitution(fp, "PRIi16", sizeof(int16_t), - signed_sub_table, signed_size_table); - - exit(0); - } - ], [ac_have_primacros_h="1"], - AC_MSG_ERROR([I could not generate replacement C99 macros for stdint types! sorry I cannot carry on!]))]) AC_DEFUN(AC_WF_CHECK_KILL_SIGNAL_DETECT, --- 45,52 ---- #include <stdlib.h> #include <inttypes.h> ! ], [uint32_t t=1; printf("%"PRIu32, t);], [AC_MSG_RESULT(found) have_primacros="yes"], AC_MSG_RESULT(not found))]) AC_DEFUN(AC_WF_CHECK_KILL_SIGNAL_DETECT, |