Skip to content

Commit e997aba

Browse files
committed
Removing atomic_ops.h from atomic.h to reduce extra dependency on Windows
1 parent c63ed32 commit e997aba

File tree

4 files changed

+49
-14
lines changed

4 files changed

+49
-14
lines changed

.gitignore

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ gc-*/
1010
out/
1111
CMakeCache.txt
1212
CMakeSettings.json
13+
CTestTestfile.cmake
1314
cmake_install.cmake
1415
cmake_uninstall.cmake
1516
Makefile
@@ -29,6 +30,33 @@ sagittarius-config
2930
sagittarius-package
3031

3132
/doc/*.html
33+
/doc/sections
34+
/ext/crypto/bytevector.c
35+
/ext/crypto/cipher.c
36+
/ext/crypto/digest.c
37+
/ext/crypto/ec-fields.c
38+
/ext/crypto/libtomcrypt/liblibtomcrypt.a
39+
/ext/crypto/mac.c
40+
/ext/crypto/modes/
41+
/ext/crypto/random.c
42+
/ext/crypto/salsa.c
43+
/ext/crypto/scrypt.stub
44+
/ext/crypto/stream.c
45+
/ext/ffi/ffi_stub.c
46+
/ext/filewatch/filewatch_stub.c
47+
/ext/odbc/odbc_stub.c
48+
/ext/perr
49+
/ext/pout
50+
/ext/process/process_stub.c
51+
/ext/socket/selector.c
52+
/ext/socket/socket_stub.c
53+
/ext/socket/tls_socket_stub.c
54+
/ext/termios/termios_stub.c
55+
/ext/threads/threads_stub.c
56+
/ext/time/date_stub.c
57+
/ext/time/time_stub.c
58+
/ext/watch
59+
/ext/zlib/zlib_stub.c
3260
/sagittarius/config.h
3361
/src/vminsn.c
3462
/src/sagittarius/private/instruction.h
@@ -51,6 +79,7 @@ sagittarius-package
5179
/src/lib_clos.c
5280
/src/lib_arith.c
5381
/src/lib_kernel.c
82+
/src/lib_atomic.c
5483
/src/compiler.c
5584
/src/compiler-aux.c
5685
/src/builtin-symbols.c

CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,6 @@ SET(SAGITTARIUS_INCLUDE_DIR ${SAGITTARIUS_INCLUDE_DIR}
283283
INCLUDE_DIRECTORIES(${SAGITTARIUS_INCLUDE_DIR})
284284

285285

286-
INCLUDE_DIRECTORIES("/opt/homebrew/include")
287286
IF(USE_BOEHM_GC)
288287
# SET(GC_DEPENDS_TARGET false)
289288
FIND_PACKAGE(Boehm_GC)

src/atomic.c

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@
3636

3737
#ifndef HAVE_STDATOMIC_H
3838

39+
#include <atomic_ops.h>
40+
3941
#define handle_memory_order(ret, proc, order, ...) \
4042
do { \
4143
switch (order) { \
@@ -196,7 +198,7 @@ static SgAtomic * make_atomic(SgAtomicType type)
196198
SgObject Sg_MakeAtomic(SgObject obj)
197199
{
198200
SgAtomic *a = make_atomic(SG_ATOMIC_OBJECT);
199-
SG_ATOMIC_REF_OBJECT(a) = (atomic_intptr_t)obj;
201+
SG_ATOMIC_REF_OBJECT(a) = (object_t)obj;
200202
return SG_OBJ(a);
201203
}
202204

@@ -214,7 +216,7 @@ SgObject Sg_AtomicLoad(volatile SgAtomic *o, SgMemoryOrder order)
214216
long v = atomic_load_explicit(&SG_ATOMIC_REF_FIXNUM(o), order);
215217
return SG_MAKE_INT(v);
216218
} else {
217-
intptr_t v = atomic_load_explicit(&SG_ATOMIC_REF_OBJECT(o), order);
219+
object_t v = atomic_load_explicit(&SG_ATOMIC_REF_OBJECT(o), order);
218220
return SG_OBJ(v);
219221
}
220222
}
@@ -227,7 +229,7 @@ void Sg_AtomicStore(volatile SgAtomic *o, SgObject v, SgMemoryOrder order)
227229
}
228230
atomic_store_explicit(&SG_ATOMIC_REF_FIXNUM(o), SG_INT_VALUE(v), order);
229231
} else {
230-
atomic_store_explicit(&SG_ATOMIC_REF_OBJECT(o), (intptr_t)v, order);
232+
atomic_store_explicit(&SG_ATOMIC_REF_OBJECT(o), (object_t)v, order);
231233
}
232234
}
233235

@@ -241,8 +243,8 @@ SgObject Sg_AtomicExchange(volatile SgAtomic *o, SgObject v, SgMemoryOrder order
241243
long l = atomic_exchange_explicit(&SG_ATOMIC_REF_FIXNUM(o), vl, order);
242244
return SG_MAKE_INT(l);
243245
} else {
244-
intptr_t r = atomic_exchange_explicit(&SG_ATOMIC_REF_OBJECT(o),
245-
(intptr_t)v, order);
246+
object_t r = atomic_exchange_explicit(&SG_ATOMIC_REF_OBJECT(o),
247+
(object_t)v, order);
246248
return SG_OBJ(r);
247249
}
248250
}
@@ -319,9 +321,9 @@ int Sg_AtomicCompareAndSwap(volatile SgAtomic *o, SgObject e, SgObject v,
319321
}
320322
default:
321323
{
322-
intptr_t ev = (intptr_t)e;
324+
object_t ev = (object_t)e;
323325
return atomic_compare_exchange_strong_explicit(&(o->reference.object),
324-
&ev, (intptr_t)v,
326+
&ev, (object_t)v,
325327
success, failure);
326328
}
327329
}

src/sagittarius/private/atomic.h

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,19 @@
3535

3636
#ifdef HAVE_STDATOMIC_H
3737
# include <stdatomic.h>
38+
# ifdef HAVE_ATOMIC_INTPTR_T
39+
typedef atomic_intptr_t atomic_object_t;
40+
typedef intptr_t object_t;
41+
# else
42+
typedef atomic_size_t atomic_object_t;
43+
typedef size_t object_t;
44+
# endif
3845
#else
39-
#include <atomic_ops.h>
46+
4047
/* We define only what we need here */
41-
typedef AO_t atomic_long;
42-
typedef AO_t atomic_size_t;
43-
typedef AO_t atomic_intptr_t;
44-
#define HAVE_ATOMIC_INTPTR_T
48+
typedef long atomic_long;
49+
typedef intptr_t atomic_object_t;
50+
typedef intptr_t object_t;
4551

4652
typedef enum memory_order {
4753
memory_order_relaxed,
@@ -53,7 +59,6 @@ typedef enum memory_order {
5359
} memory_order;
5460
#endif
5561

56-
5762
typedef memory_order SgMemoryOrder;
5863
typedef enum {
5964
SG_ATOMIC_FIXNUM,

0 commit comments

Comments
 (0)