Skip to content

Commit eb3beb1

Browse files
authored
Merge pull request #668 from sanpeqf/fixup-bfdev
feat port: added wake attribute for generic port functions
2 parents 09cadee + e95f7b6 commit eb3beb1

File tree

4 files changed

+24
-20
lines changed

4 files changed

+24
-20
lines changed

port/generic/log.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
/* TODO: PORTME */
1111

12-
int
12+
__bfdev_weak int
1313
bfport_log_write(bfdev_log_message_t *msg)
1414
{
1515
return 0;

port/generic/stdio.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
/* TODO: PORTME */
1010

11-
int
11+
__bfdev_weak int
1212
bfport_vsnprintf(char *s, bfdev_size_t maxlen, const char *fmt,
1313
bfdev_va_list arg)
1414
{

port/generic/stdlib.c

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,41 +4,45 @@
44
*/
55

66
#include <port/stdlib.h>
7+
#include <bfdev/prandom.h>
78
#include <export.h>
89

910
/* TODO: PORTME */
1011

11-
__bfdev_malloc void *
12+
static
13+
BFDEV_DEFINE_PRANDOM(generic_rand);
14+
15+
__bfdev_weak __bfdev_malloc void *
1216
bfport_malloc(bfdev_size_t size)
1317
{
1418
return BFDEV_NULL;
1519
}
1620

17-
__bfdev_malloc void *
21+
__bfdev_weak __bfdev_malloc void *
1822
bfport_calloc(bfdev_size_t nmemb, bfdev_size_t size)
1923
{
2024
return BFDEV_NULL;
2125
}
2226

23-
__bfdev_malloc void *
27+
__bfdev_weak __bfdev_malloc void *
2428
bfport_realloc(void *ptr, bfdev_size_t size)
2529
{
2630
return BFDEV_NULL;
2731
}
2832

29-
void
33+
__bfdev_weak void
3034
bfport_free(void *ptr)
3135
{
3236
return;
3337
}
3438

35-
int
39+
__bfdev_weak int
3640
bfport_rand(void)
3741
{
38-
return 0;
42+
return bfdev_prandom_value(&generic_rand);
3943
}
4044

41-
__bfdev_noreturn void
45+
__bfdev_weak __bfdev_noreturn void
4246
bfport_abort(void)
4347
{
4448
for (;;);

port/generic/string.c

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
#include <port/string.h>
77
#include <export.h>
88

9-
void *
9+
__bfdev_weak void *
1010
bfport_memcpy(void *dest, const void *src, bfdev_size_t n)
1111
{
1212
const unsigned char *nsrc;
@@ -21,7 +21,7 @@ bfport_memcpy(void *dest, const void *src, bfdev_size_t n)
2121
return dest;
2222
}
2323

24-
void *
24+
__bfdev_weak void *
2525
bfport_memset(void *s, int c, bfdev_size_t n)
2626
{
2727
unsigned char *xs;
@@ -33,7 +33,7 @@ bfport_memset(void *s, int c, bfdev_size_t n)
3333
return s;
3434
}
3535

36-
int
36+
__bfdev_weak int
3737
bfport_memcmp(const void *s1, const void *s2, bfdev_size_t n)
3838
{
3939
const unsigned char *su1, *su2;
@@ -48,7 +48,7 @@ bfport_memcmp(const void *s1, const void *s2, bfdev_size_t n)
4848
return res;
4949
}
5050

51-
int
51+
__bfdev_weak int
5252
bfport_strcmp(const char *s1, const char *s2)
5353
{
5454
int cp;
@@ -62,7 +62,7 @@ bfport_strcmp(const char *s1, const char *s2)
6262
return cp;
6363
}
6464

65-
char *
65+
__bfdev_weak char *
6666
bfport_strchr(const char *s, int c)
6767
{
6868
for (; *s != (char)c; ++s) {
@@ -73,7 +73,7 @@ bfport_strchr(const char *s, int c)
7373
return (char *)s;
7474
}
7575

76-
bfdev_size_t
76+
__bfdev_weak bfdev_size_t
7777
bfport_strspn(const char *s, const char *accept)
7878
{
7979
const unsigned char *p, *a;
@@ -93,7 +93,7 @@ bfport_strspn(const char *s, const char *accept)
9393
return count;
9494
}
9595

96-
bfdev_size_t
96+
__bfdev_weak bfdev_size_t
9797
bfport_strcspn(const char *s, const char *reject)
9898
{
9999
const unsigned char *p, *r;
@@ -111,7 +111,7 @@ bfport_strcspn(const char *s, const char *reject)
111111
return count;
112112
}
113113

114-
char *
114+
__bfdev_weak char *
115115
bfport_strcpy(char *dest, const char *src)
116116
{
117117
unsigned char *tmp;
@@ -123,7 +123,7 @@ bfport_strcpy(char *dest, const char *src)
123123
return dest;
124124
}
125125

126-
char *
126+
__bfdev_weak char *
127127
bfport_strncpy(char *dest, const char *src, bfdev_size_t n)
128128
{
129129
unsigned char *tmp;
@@ -136,7 +136,7 @@ bfport_strncpy(char *dest, const char *src, bfdev_size_t n)
136136
return dest;
137137
}
138138

139-
bfdev_size_t
139+
__bfdev_weak bfdev_size_t
140140
bfport_strlen(const char *s)
141141
{
142142
const unsigned char *len;
@@ -148,7 +148,7 @@ bfport_strlen(const char *s)
148148
return (char *)len - s;
149149
}
150150

151-
bfdev_size_t
151+
__bfdev_weak bfdev_size_t
152152
bfport_strnlen(const char *s, bfdev_size_t len)
153153
{
154154
const unsigned char *sc;

0 commit comments

Comments
 (0)