Skip to content

Commit

Permalink
Tweak inline static => INLINE or static inline
Browse files Browse the repository at this point in the history
It doesn't really make a difference, but "best practices" favor you
writing `static inline` over `inline static`.

It also turns out that just inline is only visible from within a
translation unit unless it's explicitly marked extern, so the INLINE
macro (which in C++ resolves to inline) is as good as static inline.
So using the macro is fine.

This makes the change where it makes sense.  Also fixes an accidental
change to use the INLINE macro in libuv files.
  • Loading branch information
hostilefork committed Mar 3, 2024
1 parent 5953b0f commit 788ed9f
Show file tree
Hide file tree
Showing 30 changed files with 106 additions and 106 deletions.
2 changes: 1 addition & 1 deletion extensions/crypt/mod-crypt.c
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ typedef RebolValue Value;
// specific errors. But a debug build might want to. For now, one error
// (good place to set a breakpoint).
//
inline static Value* rebMbedtlsError(int mbedtls_ret) {
INLINE Value* rebMbedtlsError(int mbedtls_ret) {
Value* result = rebValue("make error! {mbedTLS error}"); // break here
UNUSED(mbedtls_ret); // corrupts mbedtls_ret in release build
return result;
Expand Down
2 changes: 1 addition & 1 deletion extensions/filesystem/file-req.h
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ struct Reb_File_Port_State {

typedef struct Reb_File_Port_State FILEREQ;

inline static FILEREQ *File_Of_Port(const Value* port)
INLINE FILEREQ *File_Of_Port(const Value* port)
{
Value* state = CTX_VAR(VAL_CONTEXT(port), STD_PORT_STATE);
return cast(FILEREQ*, Cell_Binary_At_Ensure_Mutable(state));
Expand Down
8 changes: 4 additions & 4 deletions extensions/filesystem/libuv/src/win/fs-fd-hash-inl.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ static struct uv__fd_hash_entry_group_s
static struct uv__fd_hash_bucket_s uv__fd_hash[UV__FD_HASH_SIZE];


INLINE static void uv__fd_hash_init(void) {
inline static void uv__fd_hash_init(void) {
size_t i;
int err;

Expand Down Expand Up @@ -119,7 +119,7 @@ INLINE static void uv__fd_hash_init(void) {
FIND_IN_GROUP_PTR(UV__FD_HASH_GROUP_SIZE); \
} while (0)

INLINE static int uv__fd_hash_get(int fd, struct uv__fd_info_s* info) {
inline static int uv__fd_hash_get(int fd, struct uv__fd_info_s* info) {
FIND_COMMON_VARIABLES

uv_mutex_lock(&uv__fd_hash_mutex);
Expand All @@ -134,7 +134,7 @@ INLINE static int uv__fd_hash_get(int fd, struct uv__fd_info_s* info) {
return entry_ptr != NULL;
}

INLINE static void uv__fd_hash_add(int fd, struct uv__fd_info_s* info) {
inline static void uv__fd_hash_add(int fd, struct uv__fd_info_s* info) {
FIND_COMMON_VARIABLES

uv_mutex_lock(&uv__fd_hash_mutex);
Expand Down Expand Up @@ -164,7 +164,7 @@ INLINE static void uv__fd_hash_add(int fd, struct uv__fd_info_s* info) {
uv_mutex_unlock(&uv__fd_hash_mutex);
}

INLINE static int uv__fd_hash_remove(int fd, struct uv__fd_info_s* info) {
inline static int uv__fd_hash_remove(int fd, struct uv__fd_info_s* info) {
FIND_COMMON_VARIABLES

uv_mutex_lock(&uv__fd_hash_mutex);
Expand Down
24 changes: 12 additions & 12 deletions extensions/filesystem/libuv/src/win/fs.c
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ void uv__fs_init(void) {
}


INLINE static int fs__capture_path(uv_fs_t* req, const char* path,
inline static int fs__capture_path(uv_fs_t* req, const char* path,
const char* new_path, const int copy_path) {
char* buf;
char* pos;
Expand Down Expand Up @@ -241,7 +241,7 @@ INLINE static int fs__capture_path(uv_fs_t* req, const char* path,



INLINE static void uv__fs_req_init(uv_loop_t* loop, uv_fs_t* req,
inline static void uv__fs_req_init(uv_loop_t* loop, uv_fs_t* req,
uv_fs_type fs_type, const uv_fs_cb cb) {
uv__once_init();
UV_REQ_INIT(req, UV_FS);
Expand Down Expand Up @@ -306,7 +306,7 @@ static int fs__wide_to_utf8(WCHAR* w_source_ptr,
}


INLINE static int fs__readlink_handle(HANDLE handle, char** target_ptr,
inline static int fs__readlink_handle(HANDLE handle, char** target_ptr,
uint64_t* target_len_ptr) {
char buffer[MAXIMUM_REPARSE_DATA_BUFFER_SIZE];
REPARSE_DATA_BUFFER* reparse_data = (REPARSE_DATA_BUFFER*) buffer;
Expand Down Expand Up @@ -1248,7 +1248,7 @@ void fs__mktemp(uv_fs_t* req, uv__fs_mktemp_func func) {
size_t len;
uint64_t v;
char* path;

path = (char*)req->path;
len = wcslen(req->file.pathw);
ep = req->file.pathw + len;
Expand Down Expand Up @@ -1704,7 +1704,7 @@ void fs__closedir(uv_fs_t* req) {
SET_REQ_RESULT(req, 0);
}

INLINE static int fs__stat_handle(HANDLE handle, uv_stat_t* statbuf,
inline static int fs__stat_handle(HANDLE handle, uv_stat_t* statbuf,
int do_lstat) {
FILE_ALL_INFORMATION file_info;
FILE_FS_VOLUME_INFORMATION volume_info;
Expand Down Expand Up @@ -1849,7 +1849,7 @@ INLINE static int fs__stat_handle(HANDLE handle, uv_stat_t* statbuf,
}


INLINE static void fs__stat_prepare_path(WCHAR* pathw) {
inline static void fs__stat_prepare_path(WCHAR* pathw) {
size_t len = wcslen(pathw);

/* TODO: ignore namespaced paths. */
Expand All @@ -1860,7 +1860,7 @@ INLINE static void fs__stat_prepare_path(WCHAR* pathw) {
}


INLINE static DWORD fs__stat_impl_from_path(WCHAR* path,
inline static DWORD fs__stat_impl_from_path(WCHAR* path,
int do_lstat,
uv_stat_t* statbuf) {
HANDLE handle;
Expand Down Expand Up @@ -1892,7 +1892,7 @@ INLINE static DWORD fs__stat_impl_from_path(WCHAR* path,
}


INLINE static void fs__stat_impl(uv_fs_t* req, int do_lstat) {
inline static void fs__stat_impl(uv_fs_t* req, int do_lstat) {
DWORD error;

error = fs__stat_impl_from_path(req->file.pathw, do_lstat, &req->statbuf);
Expand Down Expand Up @@ -1960,7 +1960,7 @@ static void fs__rename(uv_fs_t* req) {
}


INLINE static void fs__sync_impl(uv_fs_t* req) {
inline static void fs__sync_impl(uv_fs_t* req) {
int fd = req->file.fd;
int result;

Expand Down Expand Up @@ -2266,7 +2266,7 @@ static void fs__fchmod(uv_fs_t* req) {
}


INLINE static int fs__utime_handle(HANDLE handle, double atime, double mtime) {
inline static int fs__utime_handle(HANDLE handle, double atime, double mtime) {
FILETIME filetime_a, filetime_m;

TIME_T_TO_FILETIME(atime, &filetime_a);
Expand All @@ -2279,7 +2279,7 @@ INLINE static int fs__utime_handle(HANDLE handle, double atime, double mtime) {
return 0;
}

INLINE static DWORD fs__utime_impl_from_path(WCHAR* path,
inline static DWORD fs__utime_impl_from_path(WCHAR* path,
double atime,
double mtime,
int do_lutime) {
Expand Down Expand Up @@ -2312,7 +2312,7 @@ INLINE static DWORD fs__utime_impl_from_path(WCHAR* path,
return ret;
}

INLINE static void fs__utime_impl(uv_fs_t* req, int do_lutime) {
inline static void fs__utime_impl(uv_fs_t* req, int do_lutime) {
DWORD error;

error = fs__utime_impl_from_path(req->file.pathw,
Expand Down
6 changes: 3 additions & 3 deletions extensions/filesystem/libuv/src/win/handle-inl.h
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@
} while (0)


INLINE static void uv__want_endgame(uv_loop_t* loop, uv_handle_t* handle) {
inline static void uv__want_endgame(uv_loop_t* loop, uv_handle_t* handle) {
if (!(handle->flags & UV_HANDLE_ENDGAME_QUEUED)) {
handle->flags |= UV_HANDLE_ENDGAME_QUEUED;

Expand All @@ -95,7 +95,7 @@ INLINE static void uv__want_endgame(uv_loop_t* loop, uv_handle_t* handle) {
}


INLINE static void uv__process_endgames(uv_loop_t* loop) {
inline static void uv__process_endgames(uv_loop_t* loop) {
uv_handle_t* handle;

while (loop->endgame_handles) {
Expand Down Expand Up @@ -163,7 +163,7 @@ INLINE static void uv__process_endgames(uv_loop_t* loop) {
}
}

INLINE static HANDLE uv__get_osfhandle(int fd)
inline static HANDLE uv__get_osfhandle(int fd)
{
/* _get_osfhandle() raises an assert in debug builds if the FD is invalid.
* But it also correctly checks the FD and returns INVALID_HANDLE_VALUE for
Expand Down
6 changes: 3 additions & 3 deletions extensions/filesystem/libuv/src/win/req-inl.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,12 +82,12 @@
}


INLINE static uv_req_t* uv__overlapped_to_req(OVERLAPPED* overlapped) {
inline static uv_req_t* uv__overlapped_to_req(OVERLAPPED* overlapped) {
return CONTAINING_RECORD(overlapped, uv_req_t, u.io.overlapped);
}


INLINE static void uv__insert_pending_req(uv_loop_t* loop, uv_req_t* req) {
inline static void uv__insert_pending_req(uv_loop_t* loop, uv_req_t* req) {
req->next_req = NULL;
if (loop->pending_reqs_tail) {
#ifdef _DEBUG
Expand Down Expand Up @@ -138,7 +138,7 @@ INLINE static void uv__insert_pending_req(uv_loop_t* loop, uv_req_t* req) {
} while (0)


INLINE static void uv__process_reqs(uv_loop_t* loop) {
inline static void uv__process_reqs(uv_loop_t* loop) {
uv_req_t* req;
uv_req_t* first;
uv_req_t* next;
Expand Down
4 changes: 2 additions & 2 deletions extensions/filesystem/libuv/src/win/stream-inl.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
#include "req-inl.h"


INLINE static void uv__stream_init(uv_loop_t* loop,
inline static void uv__stream_init(uv_loop_t* loop,
uv_stream_t* handle,
uv_handle_type type) {
uv__handle_init(loop, (uv_handle_t*) handle, type);
Expand All @@ -46,7 +46,7 @@ INLINE static void uv__stream_init(uv_loop_t* loop,
}


INLINE static void uv__connection_init(uv_stream_t* handle) {
inline static void uv__connection_init(uv_stream_t* handle) {
handle->flags |= UV_HANDLE_CONNECTION;
}

Expand Down
2 changes: 1 addition & 1 deletion extensions/filesystem/mod-filesystem.c
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ enum {
PATH_OPT_SRC_IS_DIR = 1 << 0
};

inline static bool Last_In_Mold_Is_Slash(REB_MOLD *mo) {
INLINE bool Last_In_Mold_Is_Slash(REB_MOLD *mo) {
if (mo->base.size == Series_Used(mo->series))
return false; // nothing added yet

Expand Down
2 changes: 1 addition & 1 deletion extensions/filesystem/p-file.c
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ extern Value* Rename_File_Or_Directory(const Value* port, const Value* to);
extern Value* Truncate_File(const Value* port);


inline static uint64_t File_Size_Cacheable_May_Fail(const Value* port)
INLINE uint64_t File_Size_Cacheable_May_Fail(const Value* port)
{
uint64_t size;
Value* error = Get_File_Size_Cacheable(&size, port);
Expand Down
16 changes: 8 additions & 8 deletions extensions/javascript/mod-javascript.c
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@

static bool PG_JS_Trace = false; // Turned on/off with JS-TRACE native

inline static void Javascript_Trace_Helper_Debug(const char *buf) {
INLINE void Javascript_Trace_Helper_Debug(const char *buf) {
if (PG_JS_Trace) {
printf("@%ld: %s\n", cast(long, TG_tick), buf); // prefix ticks
fflush(stdout); // just to be safe
Expand Down Expand Up @@ -188,13 +188,13 @@

typedef unsigned int heapaddr_t;

inline static heapaddr_t Heapaddr_From_Pointer(const void *p) {
INLINE heapaddr_t Heapaddr_From_Pointer(const void *p) {
uintptr_t u = i_cast(uintptr_t, p);
assert(u < UINT_MAX);
return u;
}

inline static void* Pointer_From_Heapaddr(heapaddr_t addr)
INLINE void* Pointer_From_Heapaddr(heapaddr_t addr)
{ return p_cast(void*, cast(uintptr_t, addr)); }

static void cleanup_js_object(const Value* v) {
Expand Down Expand Up @@ -228,15 +228,15 @@ static void cleanup_js_object(const Value* v) {
// from JavaScript code may only be caught by JavaScript code."
//

inline static heapaddr_t Level_Id_For_Level(Level* L) {
INLINE heapaddr_t Level_Id_For_Level(Level* L) {
return Heapaddr_From_Pointer(L);
}

inline static Level* Level_From_Level_Id(heapaddr_t id) {
INLINE Level* Level_From_Level_Id(heapaddr_t id) {
return cast(Level*, Pointer_From_Heapaddr(id));
}

inline static Value* Value_From_Value_Id(heapaddr_t id) {
INLINE Value* Value_From_Value_Id(heapaddr_t id) {
if (id == 0)
return nullptr;

Expand All @@ -262,7 +262,7 @@ inline static Value* Value_From_Value_Id(heapaddr_t id) {
// was put in that table at the time of creation (the native_id).
//

inline static heapaddr_t Native_Id_For_Action(Action* act)
INLINE heapaddr_t Native_Id_For_Action(Action* act)
{ return Heapaddr_From_Pointer(ACT_IDENTITY(act)); }

enum {
Expand Down Expand Up @@ -972,7 +972,7 @@ DECLARE_NATIVE(js_native)
// "Evaluate textual JavaScript code"
//
// return: "Note: Only supports types that reb.Box() supports"
// [~ ~null~ logic? integer! text!]
// [~ <opt> logic? integer! text!]
// source "JavaScript code as a text string" [text!]
// /local "Evaluate in local scope (as opposed to global)"
// /value "Return a Rebol value"
Expand Down
2 changes: 1 addition & 1 deletion extensions/network/reb-net.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ struct Reb_Sock_Port_State {

typedef struct Reb_Sock_Port_State SOCKREQ;

inline static SOCKREQ *Sock_Of_Port(const Value* port)
INLINE SOCKREQ *Sock_Of_Port(const Value* port)
{
Value* state = CTX_VAR(VAL_CONTEXT(port), STD_PORT_STATE);
return VAL_HANDLE_POINTER(SOCKREQ, state);
Expand Down
8 changes: 4 additions & 4 deletions extensions/process/call-posix.c
Original file line number Diff line number Diff line change
Expand Up @@ -61,19 +61,19 @@

#include "reb-process.h"

static inline bool retry_read(int nbytes) {
INLINE bool retry_read(int nbytes) {
return nbytes < 0 && (errno == EAGAIN || errno == EINTR);
}

static inline ssize_t safe_read(int f, void*b, size_t c) {
INLINE ssize_t safe_read(int f, void*b, size_t c) {
read_again: ;
ssize_t r = read(f,b,c);
if (retry_read(r))
goto read_again;
return r;
}

inline static bool Open_Pipe_Fails(int pipefd[2]) {
INLINE bool Open_Pipe_Fails(int pipefd[2]) {
#ifdef USE_PIPE2_NOT_PIPE
//
// NOTE: pipe() is POSIX, but pipe2() is Linux-specific. With pipe() it
Expand Down Expand Up @@ -107,7 +107,7 @@ inline static bool Open_Pipe_Fails(int pipefd[2]) {
return false;
}

inline static bool Set_Nonblocking_Fails(int fd) {
INLINE bool Set_Nonblocking_Fails(int fd) {
int oldflags = fcntl(fd, F_GETFL);
if (oldflags < 0)
return true;
Expand Down
6 changes: 3 additions & 3 deletions extensions/process/reb-process.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,20 +24,20 @@


ATTRIBUTE_NO_RETURN
inline static void Fail_Permission_Denied(void) {
INLINE void Fail_Permission_Denied(void) {
rebJumps("fail {The process does not have enough permission}");
}

ATTRIBUTE_NO_RETURN
inline static void Fail_No_Process(const Value* arg) {
INLINE void Fail_No_Process(const Value* arg) {
rebJumps(
"fail [{The target process (group) does not exist:}", arg, "]"
);
}

#if TO_WINDOWS
ATTRIBUTE_NO_RETURN
inline static void Fail_Terminate_Failed(DWORD err) { // GetLastError()
INLINE void Fail_Terminate_Failed(DWORD err) { // GetLastError()
rebJumps(
"fail [{Terminate failed with error number:}", rebI(err), "]"
);
Expand Down
6 changes: 3 additions & 3 deletions extensions/stdio/readline-posix.c
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ enum {
};


inline static void WRITE_UTF8(const unsigned char *utf8, size_t size) {
INLINE void WRITE_UTF8(const unsigned char *utf8, size_t size) {
if (write(STDOUT_FILENO, utf8, size) == -1) {
/* Error here, or better to "just try to keep going"? */
}
Expand Down Expand Up @@ -98,10 +98,10 @@ struct Reb_Terminal_Struct {
static bool Term_Initialized = false; // Terminal init was successful


inline static unsigned int Term_End(STD_TERM *t)
INLINE unsigned int Term_End(STD_TERM *t)
{ return rebUnboxInteger("length of", t->buffer); }

inline static unsigned int Term_Remain(STD_TERM *t)
INLINE unsigned int Term_Remain(STD_TERM *t)
{ return Term_End(t) - t->pos; }


Expand Down
Loading

0 comments on commit 788ed9f

Please sign in to comment.