Skip to content

Commit

Permalink
Fix R bool collision and cpp namespace
Browse files Browse the repository at this point in the history
  • Loading branch information
andrjohns committed May 31, 2024
1 parent 885d20d commit a83a42a
Showing 1 changed file with 20 additions and 8 deletions.
28 changes: 20 additions & 8 deletions cutils.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* C utilities
*
*
* Copyright (c) 2017 Fabrice Bellard
* Copyright (c) 2018 Charlie Gordon
*
Expand Down Expand Up @@ -28,6 +28,12 @@
#include <stdlib.h>
#include <inttypes.h>

#ifdef STRICT_R_HEADERS
#ifdef __cplusplus
extern "C" {
#endif
#endif

/* set if CPU is big endian */
#undef WORDS_BIGENDIAN

Expand All @@ -54,12 +60,14 @@

typedef int BOOL;

#ifndef STRICT_R_HEADERS
#ifndef FALSE
enum {
FALSE = 0,
TRUE = 1,
};
#endif
#endif

void pstrcpy(char *buf, int buf_size, const char *str);
char *pstrcat(char *buf, int buf_size, const char *s);
Expand Down Expand Up @@ -223,13 +231,13 @@ static inline uint32_t bswap32(uint32_t v)

static inline uint64_t bswap64(uint64_t v)
{
return ((v & ((uint64_t)0xff << (7 * 8))) >> (7 * 8)) |
((v & ((uint64_t)0xff << (6 * 8))) >> (5 * 8)) |
((v & ((uint64_t)0xff << (5 * 8))) >> (3 * 8)) |
((v & ((uint64_t)0xff << (4 * 8))) >> (1 * 8)) |
((v & ((uint64_t)0xff << (3 * 8))) << (1 * 8)) |
((v & ((uint64_t)0xff << (2 * 8))) << (3 * 8)) |
((v & ((uint64_t)0xff << (1 * 8))) << (5 * 8)) |
return ((v & ((uint64_t)0xff << (7 * 8))) >> (7 * 8)) |
((v & ((uint64_t)0xff << (6 * 8))) >> (5 * 8)) |
((v & ((uint64_t)0xff << (5 * 8))) >> (3 * 8)) |
((v & ((uint64_t)0xff << (4 * 8))) >> (1 * 8)) |
((v & ((uint64_t)0xff << (3 * 8))) << (1 * 8)) |
((v & ((uint64_t)0xff << (2 * 8))) << (3 * 8)) |
((v & ((uint64_t)0xff << (1 * 8))) << (5 * 8)) |
((v & ((uint64_t)0xff << (0 * 8))) << (7 * 8));
}

Expand Down Expand Up @@ -297,4 +305,8 @@ void rqsort(void *base, size_t nmemb, size_t size,
int (*cmp)(const void *, const void *, void *),
void *arg);

#ifdef __cplusplus
} /* extern "C" { */
#endif

#endif /* CUTILS_H */

0 comments on commit a83a42a

Please sign in to comment.