Skip to content

Commit

Permalink
Fix compile with musl
Browse files Browse the repository at this point in the history
  • Loading branch information
root authored and root committed Feb 16, 2024
1 parent faa8a05 commit f732a89
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 4 deletions.
2 changes: 1 addition & 1 deletion adb/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ LOCAL_STATIC_LIBRARIES := libcutils libc
################################

OBJS = $(LOCAL_SRC_FILES:.cpp=.o) $(LOCAL_SRC_C_FILES:.c=.o)
CXXFLAGS = $(OPT_CXXFLAGS) -std=c++14 $(LOCAL_CFLAGS) $(LOCAL_INCLUDES)
CXXFLAGS = $(OPT_CXXFLAGS) -std=gnu++14 $(LOCAL_CFLAGS) $(LOCAL_INCLUDES)
CFLAGS= $(OPT_CFLAGS) $(LOCAL_CFLAGS) $(LOCAL_INCLUDES)

%.o: %.cpp
Expand Down
4 changes: 4 additions & 0 deletions adb/diagnose_usb.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@

static const char kPermissionsHelpUrl[] = "http://developer.android.com/tools/device.html";

__attribute__((weak)) int group_member(gid_t gid) {
return 0;
}

// Returns a message describing any potential problems we find with udev, or nullptr if we can't
// find plugdev information (i.e. udev is not installed).
static const char* GetUdevProblem() {
Expand Down
6 changes: 6 additions & 0 deletions base/file.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,12 @@
#define LOG_TAG "base.file"
#include "cutils/log.h"
#include "utils/Compat.h"
#include <sys/stat.h>

/* speciaally for musl c */
#ifndef DEFFILEMODE
# define DEFFILEMODE (S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH)/* 0666*/
#endif

namespace android {
namespace base {
Expand Down
6 changes: 3 additions & 3 deletions base/logging.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,11 +93,11 @@ namespace {
using std::mutex;
using std::lock_guard;

#if defined(__GLIBC__)
const char* getprogname() {
//#if defined(__GLIBC__)
const char* __attribute__((weak)) getprogname() {
return program_invocation_short_name;
}
#endif
//#endif

#else
const char* getprogname() {
Expand Down
8 changes: 8 additions & 0 deletions include/cutils/android_reboot.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,14 @@

#include <mntent.h>

#if defined(__cplusplus)
#define __BEGIN_DECLS extern "C" {
#define __END_DECLS }
#else
#define __BEGIN_DECLS
#define __END_DECLS
#endif

__BEGIN_DECLS

/* Commands */
Expand Down

0 comments on commit f732a89

Please sign in to comment.