소스 검색

Merge pull request #230 from Red54/patch-1

Add support for GCC below 4.1.0 - note that it will not be thread save for older GCC version (without __sync_fetch_and_add)
bel2125 9 년 전
부모
커밋
f1ef34d561
1개의 변경된 파일2개의 추가작업 그리고 2개의 파일을 삭제
  1. 2 2
      src/civetweb.c

+ 2 - 2
src/civetweb.c

@@ -1253,7 +1253,7 @@ mg_atomic_inc(volatile int *addr)
 	 * (volatile unsigned int *) or (volatile LONG *),
 	 * so whatever you use, the other SDK is likely to raise a warning. */
 	ret = InterlockedIncrement((volatile long *)addr);
-#elif defined(__GNUC__)
+#elif defined(__GNUC__) && (__GNUC__ > 5 || (__GNUC__ == 4 && __GNUC_MINOR__ > 0))
 	ret = __sync_add_and_fetch(addr, 1);
 #else
 	ret = (++(*addr));
@@ -1270,7 +1270,7 @@ mg_atomic_dec(volatile int *addr)
 	 * (volatile unsigned int *) or (volatile LONG *),
 	 * so whatever you use, the other SDK is likely to raise a warning. */
 	ret = InterlockedDecrement((volatile long *)addr);
-#elif defined(__GNUC__)
+#elif defined(__GNUC__) && (__GNUC__ > 5 || (__GNUC__ == 4 && __GNUC_MINOR__ > 0))
 	ret = __sync_sub_and_fetch(addr, 1);
 #else
 	ret = (--(*addr));