Skip to content

Commit ae9a8d1

Browse files
committed
Remove macros, use inline function.
1 parent b019860 commit ae9a8d1

File tree

23 files changed

+350
-407
lines changed

23 files changed

+350
-407
lines changed

Makefile

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ VERSION = 1.9
4646
##########################
4747

4848
CC = cc
49+
CXX = g++
4950
AR = ar
5051
LD = ld
5152
RANLIB = ranlib
@@ -184,16 +185,23 @@ endif
184185
# make EXTRA_CFLAGS=-UMD_HAVE_EPOLL <target>
185186
#
186187
# or to enable sendmmsg(2) support:
187-
#
188188
# make EXTRA_CFLAGS="-DMD_HAVE_SENDMMSG -D_GNU_SOURCE"
189189
#
190190
# or to enable stats for ST:
191-
#
192191
# make EXTRA_CFLAGS=-DDEBUG_STATS
193192
#
194193
# or cache the stack and reuse it:
195194
# make EXTRA_CFLAGS=-DMD_CACHE_STACK
196195
#
196+
# or enable support for valgrind:
197+
# make EXTRA_CFLAGS="-DMD_VALGRIND"
198+
#
199+
# or enable support for asan:
200+
# make EXTRA_CFLAGS="-DMD_ASAN -fsanitize=address -fno-omit-frame-pointer"
201+
#
202+
# or to disable the clock_gettime for MacOS before 10.12, see https://github.com/ossrs/srs/issues/3978
203+
# make EXTRA_CFLAGS=-DMD_OSX_NO_CLOCK_GETTIME
204+
#
197205
# or enable the coverage for utest:
198206
# make UTEST_FLAGS="-fprofile-arcs -ftest-coverage"
199207
#
@@ -207,7 +215,8 @@ OBJS = $(TARGETDIR)/sched.o \
207215
$(TARGETDIR)/sync.o \
208216
$(TARGETDIR)/key.o \
209217
$(TARGETDIR)/io.o \
210-
$(TARGETDIR)/event.o
218+
$(TARGETDIR)/event.o \
219+
$(TARGETDIR)/common.o
211220
OBJS += $(EXTRA_OBJS)
212221
HEADER = $(TARGETDIR)/st.h
213222
SLIBRARY = $(TARGETDIR)/libst.a
@@ -270,21 +279,16 @@ $(HEADER): public.h
270279
rm -f $@
271280
cp public.h $@
272281

273-
$(TARGETDIR)/md_linux.o: md_linux.S
274-
$(CC) $(CFLAGS) -c $< -o $@
275-
276-
$(TARGETDIR)/md_linux2.o: md_linux2.S
277-
$(CC) $(CFLAGS) -c $< -o $@
278-
279-
$(TARGETDIR)/md_darwin.o: md_darwin.S
280-
$(CC) $(CFLAGS) -c $< -o $@
281-
282-
$(TARGETDIR)/md_cygwin64.o: md_cygwin64.S
282+
$(TARGETDIR)/%.o: %.S
283283
$(CC) $(CFLAGS) -c $< -o $@
284284

285285
$(TARGETDIR)/%.o: %.c common.h md.h
286286
$(CC) $(CFLAGS) -c $< -o $@
287287

288+
# Note that we use C++98 standard for the C++ files.
289+
$(TARGETDIR)/%.o: %.cc common.h md.h
290+
$(CXX) $(CFLAGS) -c $< -o $@ -std=c++98
291+
288292
clean:
289293
rm -rf *_OPT *_DBG obj st.pc
290294

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,12 @@ Linux with valgrind and epoll:
5151
make linux-debug EXTRA_CFLAGS="-DMD_HAVE_EPOLL -DMD_VALGRIND"
5252
```
5353

54+
Linux with ASAN(Google Address Sanitizer):
55+
56+
```bash
57+
make linux-debug EXTRA_CFLAGS="-DMD_ASAN"
58+
```
59+
5460
## Mac: Usage
5561

5662
Get code:

common.c

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
/* SPDX-License-Identifier: MIT */
2+
/* Copyright (c) 2021-2022 The SRS Authors */
3+
4+
#include "common.h"
5+
6+
void *_st_primordial_stack_bottom = NULL;
7+
size_t _st_primordial_stack_size = 0;
8+
9+
void st_set_primordial_stack(void *top, void *bottom)
10+
{
11+
_st_primordial_stack_bottom = bottom;
12+
_st_primordial_stack_size = (char *)top - (char *)bottom;
13+
}
14+

0 commit comments

Comments
 (0)