Skip to content

Commit 8ed9e11

Browse files
committed
some portability improvements
1 parent 36868a0 commit 8ed9e11

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

dirpath.c

+15
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,21 @@ char *get_exename(char *buf, size_t size)
7979

8080
return buf;
8181
}
82+
#elif defined(__FreeBSD__)
83+
#include <sys/types.h>
84+
#include <sys/sysctl.h>
85+
86+
char *get_exename(char *buf, size_t size)
87+
{
88+
int mib[4];
89+
mib[0] = CTL_KERN;
90+
mib[1] = KERN_PROC;
91+
mib[2] = KERN_PROC_PATHNAME;
92+
mib[3] = -1;
93+
sysctl(mib, 4, buf, &size, NULL, 0);
94+
95+
return buf;
96+
}
8297
#elif defined(WIN32)
8398
char *get_exename(char *buf, size_t size)
8499
{

utf8.c

+2
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,9 @@
2424
#include <malloc.h>
2525
#define snprintf _snprintf
2626
#else
27+
#ifndef __FreeBSD__
2728
#include <alloca.h>
29+
#endif /* __FreeBSD__ */
2830
#endif
2931
#include <assert.h>
3032

0 commit comments

Comments
 (0)