Changeset 481 for trunk/aclocal.m4
- Timestamp:
- Jul 18, 2015, 5:06:52 PM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/aclocal.m4
r476 r481 264 264 AC_MSG_RESULT($sh_cv_typedef) 265 265 if test "$sh_cv_typedef" = yes; then 266 AC_DEFINE( $2)266 AC_DEFINE([$2], [1], [Define if type is defined in stdint.h or inttypes.h]) 267 267 sh_$2=yes 268 268 else … … 276 276 dnl *** va_copy checks *** 277 277 dnl ********************** 278 # va_copy.m4 serial 1 (js-1.6.20070208) 279 280 dnl ## From the OpenWrt Project (http://openwrt.org) 281 dnl ## Project is GPL v2 282 dnl ## 283 dnl ## 284 dnl ## Check for C99 va_copy() implementation 285 dnl ## (and provide fallback implementation if neccessary) 286 dnl ## 287 dnl ## configure.in: 288 dnl ## AC_CHECK_VA_COPY 289 dnl ## foo.c: 290 dnl ## #include "config.h" 291 dnl ## [...] 292 dnl ## va_copy(d,s) 293 dnl ## 294 dnl ## This check is rather complex: first because we really have to 295 dnl ## try various possible implementations in sequence and second, we 296 dnl ## cannot define a macro in config.h with parameters directly. 297 dnl ## 298 299 dnl # test program for va_copy() implementation 300 changequote(<<,>>) 301 m4_define(__va_copy_test, <<[ 302 #include <stdlib.h> 303 #include <stdarg.h> 304 #include <string.h> 305 #define DO_VA_COPY(d, s) $1 306 void test(char *str, ...) 307 { 308 va_list ap, ap2; 309 int i; 310 va_start(ap, str); 311 DO_VA_COPY(ap2, ap); 312 for (i = 1; i <= 9; i++) { 313 int k = (int)va_arg(ap, int); 314 if (k != i) 315 abort(); 316 } 317 DO_VA_COPY(ap, ap2); 318 for (i = 1; i <= 9; i++) { 319 int k = (int)va_arg(ap, int); 320 if (k != i) 321 abort(); 322 } 323 va_end(ap); 324 } 325 int main(int argc, char *argv[]) 326 { 327 test("test", 1, 2, 3, 4, 5, 6, 7, 8, 9); 328 exit(0); 329 } 330 ]>>) 331 changequote([,]) 332 333 dnl # test driver for va_copy() implementation 334 m4_define(__va_copy_check, [ 335 AH_VERBATIM($1, 336 [/* Predefined possible va_copy() implementation (id: $1) */ 337 #define __VA_COPY_USE_$1(d, s) $2]) 338 if test ".$ac_cv_va_copy" = .; then 339 AC_TRY_RUN(__va_copy_test($2), [ac_cv_va_copy="$1"]) 340 fi 278 AC_DEFUN([SL_CHECK_VA_COPY], 279 [AC_MSG_CHECKING(for va_copy()) 280 AC_CACHE_VAL(sh_cv_va_copy,[ 281 AC_TRY_RUN([ 282 #include <stdarg.h> 283 void f (int i, ...) { 284 va_list args1, args2; 285 va_start (args1, i); 286 va_copy (args2, args1); 287 if (va_arg (args2, int) != 42) 288 exit (1); 289 if (va_arg (args1, int) != 42) 290 exit (1); 291 va_end (args1); va_end (args2); 292 } 293 int main() { 294 f (0, 42); 295 return 0; 296 }], 297 sh_cv_va_copy=yes 298 , 299 sh_cv_va_copy=no 300 , 301 sh_cv_va_copy=no) 341 302 ]) 342 343 dnl # Autoconf check for va_copy() implementation checking 344 AC_DEFUN([AC_CHECK_VA_COPY],[ 345 dnl # provide Autoconf display check message 346 AC_MSG_CHECKING(for va_copy() function) 347 dnl # check for various implementations in priorized sequence 348 AC_CACHE_VAL(ac_cv_va_copy, [ 349 ac_cv_va_copy="" 350 dnl # 1. check for standardized C99 macro 351 __va_copy_check(C99, [va_copy((d), (s))]) 352 dnl # 2. check for alternative/deprecated GCC macro 353 __va_copy_check(GCM, [VA_COPY((d), (s))]) 354 dnl # 3. check for internal GCC macro (high-level define) 355 __va_copy_check(GCH, [__va_copy((d), (s))]) 356 dnl # 4. check for internal GCC macro (built-in function) 357 __va_copy_check(GCB, [__builtin_va_copy((d), (s))]) 358 dnl # 5. check for assignment approach (assuming va_list is a struct) 359 __va_copy_check(ASS, [do { (d) = (s); } while (0)]) 360 dnl # 6. check for assignment approach (assuming va_list is a pointer) 361 __va_copy_check(ASP, [do { *(d) = *(s); } while (0)]) 362 dnl # 7. check for memory copying approach (assuming va_list is a struct) 363 __va_copy_check(CPS, [memcpy((void *)&(d), (void *)&(s)), sizeof((s))]) 364 dnl # 8. check for memory copying approach (assuming va_list is a pointer) 365 __va_copy_check(CPP, [memcpy((void *)(d), (void *)(s)), sizeof(*(s))]) 366 if test ".$ac_cv_va_copy" = .; then 367 AC_ERROR([no working implementation found]) 368 fi 369 ]) 370 dnl # optionally activate the fallback implementation 371 if test ".$ac_cv_va_copy" = ".C99"; then 372 AC_DEFINE(HAVE_VA_COPY, 1, [Define if va_copy() macro exists (and no fallback implementation is required)]) 373 fi 374 dnl # declare which fallback implementation to actually use 375 AC_DEFINE_UNQUOTED([__VA_COPY_USE], [__VA_COPY_USE_$ac_cv_va_copy], 376 [Define to id of used va_copy() implementation]) 377 dnl # provide activation hook for fallback implementation 378 AH_VERBATIM([__VA_COPY_ACTIVATION], 379 [/* Optional va_copy() implementation activation */ 380 #ifndef HAVE_VA_COPY 381 #define va_copy(d, s) __VA_COPY_USE(d, s) 382 #endif 303 AC_MSG_RESULT($sh_cv_va_copy) 304 AC_MSG_CHECKING(for __va_copy()) 305 AC_CACHE_VAL(sh_cv___va_copy,[ 306 AC_TRY_RUN([ 307 #include <stdarg.h> 308 void f (int i, ...) { 309 va_list args1, args2; 310 va_start (args1, i); 311 __va_copy (args2, args1); 312 if (va_arg (args2, int) != 42) 313 exit (1); 314 if (va_arg (args1, int) != 42) 315 exit (1); 316 va_end (args1); va_end (args2); 317 } 318 int main() { 319 f (0, 42); 320 return 0; 321 }], 322 sh_cv___va_copy=yes 323 , 324 sh_cv___va_copy=no 325 , 326 sh_cv___va_copy=no) 383 327 ]) 384 dnl # provide Autoconf display result message 385 if test ".$ac_cv_va_copy" = ".C99"; then 386 AC_MSG_RESULT([yes]) 387 else 388 AC_MSG_RESULT([no (using fallback implementation)]) 389 fi 328 AC_MSG_RESULT($sh_cv___va_copy) 329 AC_MSG_CHECKING(whether va_lists can be copied by value) 330 AC_CACHE_VAL(sh_cv_va_val_copy,[ 331 AC_TRY_RUN([ 332 #include <stdarg.h> 333 void f (int i, ...) { 334 va_list args1, args2; 335 va_start (args1, i); 336 args2 = args1; 337 if (va_arg (args2, int) != 42) 338 exit (1); 339 if (va_arg (args1, int) != 42) 340 exit (1); 341 va_end (args1); va_end (args2); 342 } 343 int main() { 344 f (0, 42); 345 return 0; 346 }], 347 sh_cv_va_val_copy=yes 348 , 349 sh_cv_va_val_copy=no 350 , 351 sh_cv_va_val_copy=no) 352 ]) 353 if test "x$sh_cv_va_copy" = "xyes"; then 354 AC_DEFINE(VA_COPY, va_copy) 355 else if test "x$sh_cv___va_copy" = "xyes"; then 356 AC_DEFINE(VA_COPY, __va_copy) 357 fi 358 fi 359 if test "x$sh_cv_va_val_copy" = "xno"; then 360 AC_DEFINE(VA_COPY_AS_ARRAY) 361 fi 362 AC_MSG_RESULT($sh_cv_va_val_copy) 390 363 ]) 391 364
Note:
See TracChangeset
for help on using the changeset viewer.