Skip to content

Commit

Permalink
LibC: Don't export ALWAYS_INLINE from sys/cdefs.h
Browse files Browse the repository at this point in the history
POSIX doesn't tell us to export a macro like this, and it's largely
going to never be defined when compiling a serenity-native C++ file,
since AK defines it already.

This does raise a strange issue where some futex-related helpers in
serenity.h are declared with ALWAYS_INLINE. Whether these helpers belong
in a C-visible header as file-static methods is questionable, but let's
work around the issue but adding some preprocessor magic to make sure
these declarations get the behavior they used to have without leaking
macros.
  • Loading branch information
ADKaster authored and bgianfo committed Mar 1, 2022
1 parent 8dd08a1 commit fcb6431
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
9 changes: 9 additions & 0 deletions Userland/Libraries/LibC/serenity.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@ int profiling_free_buffer(pid_t);

int futex(uint32_t* userspace_address, int futex_op, uint32_t value, const struct timespec* timeout, uint32_t* userspace_address2, uint32_t value3);

#ifndef ALWAYS_INLINE
# define ALWAYS_INLINE inline __attribute__((always_inline))
# define ALWAYS_INLINE_SERENITY_H
#endif

static ALWAYS_INLINE int futex_wait(uint32_t* userspace_address, uint32_t value, const struct timespec* abstime, int clockid)
{
int op;
Expand All @@ -42,6 +47,10 @@ static ALWAYS_INLINE int futex_wake(uint32_t* userspace_address, uint32_t count)
return futex(userspace_address, FUTEX_WAKE, count, NULL, NULL, 0);
}

#ifdef ALWAYS_INLINE_SERENITY_H
# undef ALWAYS_INLINE
#endif

int purge(int mode);

int perf_event(int type, uintptr_t arg1, uintptr_t arg2);
Expand Down
4 changes: 0 additions & 4 deletions Userland/Libraries/LibC/sys/cdefs.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,6 @@

#define _POSIX_VERSION 200809L

#ifndef ALWAYS_INLINE
# define ALWAYS_INLINE inline __attribute__((always_inline))
#endif

#ifdef __cplusplus
# ifndef __BEGIN_DECLS
# define __BEGIN_DECLS extern "C" {
Expand Down

0 comments on commit fcb6431

Please sign in to comment.