Code Monkey home page Code Monkey logo

Comments (5)

bel2125 avatar bel2125 commented on June 10, 2024

Interesting that Android removed __sync_add_and_fetch. Did they offer any replacement for this?

https://github.com/civetweb/civetweb/blob/master/examples/ws_server/ws_server.c#L48 is only an example code, not part of the portable web server core. This example probably only runs on Linux, also not on Windows. It could be changed to use #if defined(WIN32) ... #elif defined(OSX) ... #elif defined(LINUX) ... #elif define(ANDROID) && (NDK_Version>23) ... #elif define(ANDROID) && (NDK_Version<=23) ... #else .... #endif and using a pthread_mutex or CriticalSession or any other operating system or library depending lock mechanism.

from civetweb.

mavavilj avatar mavavilj commented on June 10, 2024

android/ndk#1231 ?

from civetweb.

bel2125 avatar bel2125 commented on June 10, 2024

There I read the android development switched from GCC to CLANG.
But __sync_add_and_fetch is provided by clang, provided you use a recent version (llvm/llvm-project#62084).

Although, it could be the new version needs __atomic_add_fetch instead of the older __sync_add_and_fetch - unfortunately this change will break the build for older compilers.

from civetweb.

bel2125 avatar bel2125 commented on June 10, 2024

Android used to use __snyc_add_and_fetch (https://android.googlesource.com/platform/art/+/2ec6520/runtime/atomic.h)

Now it is probably int32_t android_atomic_add(int32_t value, volatile int32_t* addr); (https://android.googlesource.com/platform/system/core/+/ac322da/include/cutils/atomic.h#41).
I cannot really find a good source on this and I did not download the new NDK yet - this may take a while to check.

from civetweb.

mavavilj avatar mavavilj commented on June 10, 2024

But I also believe that all NDK versions should work with all SDK versions, so in this sense an upgrade just for this library is not necessary. However, then it's not possible to mix it with libraries that work with NDK >= 23.

The below snippet suggests that the replacement is android_atomic_inc(&value_) + 1;

https://android.googlesource.com/platform/art/+/b122a4b%5E%21/

-  int32_t operator++() {
-    return android_atomic_inc(&value_) + 1;
+  int32_t operator++() {  // Prefix operator.
+    return __sync_add_and_fetch(&value_, 1);  // Return new value.
   }

from civetweb.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.