Skip to content

Commit

Permalink
Merge branch 'bugfix/linux_target_mac' into 'master'
Browse files Browse the repository at this point in the history
fix(linux): fixed build errors on MacOS

Closes IDF-9791

See merge request espressif/esp-idf!30525
  • Loading branch information
0xjakob committed May 6, 2024
2 parents f311c23 + 2f0ef33 commit 8c51cc6
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
6 changes: 6 additions & 0 deletions components/esp_hw_support/port/linux/esp_random.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,13 @@
#include <stddef.h>
#include <stdint.h>
#include <assert.h>

// getentropy live in different header files on Mac and Linux
#if (defined(__APPLE__) && defined(__MACH__))
#include <sys/random.h>
#else
#include <unistd.h>
#endif

#include "esp_log.h"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,20 @@

#pragma once

#if (defined(__APPLE__) && defined(__MACH__))
// MacOS

#if !defined(__containerof)
#define __containerof(ptr, type, member) ({ \
const typeof( ((type *)0)->member ) *__mptr = (ptr); \
(type *)( (char *)__mptr - offsetof(type,member) );})
#endif

#include_next <sys/cdefs.h> // include the actual cdefs.h (which does not contain containerof)

#else
// Linux

#include <stdint.h>

// We need a define. We can't typedef here since, depending on the include order,
Expand All @@ -20,3 +34,5 @@

#include_next <sys/cdefs.h>
#include <bsd/sys/cdefs.h>

#endif

0 comments on commit 8c51cc6

Please sign in to comment.