Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Tales of MajEyal
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Otowa Kotori
Tales of MajEyal
Commits
ae37dbd8
Commit
ae37dbd8
authored
8 years ago
by
DarkGod
Browse files
Options
Downloads
Patches
Plain Diff
BSD improvments
parent
3629d983
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/getself.c
+10
-8
10 additions, 8 deletions
src/getself.c
with
10 additions
and
8 deletions
src/getself.c
+
10
−
8
View file @
ae37dbd8
...
...
@@ -42,12 +42,18 @@ int get_number_cpus()
#elif defined(SELFEXE_BSD)
#include
<limits.h>
#include
<stdlib.h>
#include
<unistd.h>
#include
<sys/sysctl.h>
const
char
*
get_self_executable
(
int
argc
,
char
**
argv
)
{
static
char
res
[
PATH_MAX
];
// Like linux, but /proc is not always mounted
// return 0 if it's not
if
(
realpath
(
"/proc/curproc/file"
,
res
))
return
NULL
;
int
mib
[
4
];
mib
[
0
]
=
CTL_KERN
;
mib
[
1
]
=
KERN_PROC
;
mib
[
2
]
=
KERN_PROC_PATHNAME
;
mib
[
3
]
=
-
1
;
size_t
cb
=
sizeof
(
res
);
sysctl
(
mib
,
4
,
res
,
&
cb
,
NULL
,
0
);
return
res
;
}
...
...
@@ -55,11 +61,7 @@ const char *get_self_executable(int argc, char **argv)
int
get_number_cpus
()
{
int
count
;
size_t
size
=
sizeof
(
count
);
if
(
sysctlbyname
(
"hw.ncpu"
,
&
count
,
&
size
,
NULL
,
0
))
return
1
;
return
count
;
return
sysconf
(
_SC_NPROCESSORS_ONLN
);
}
#elif defined(SELFEXE_WINDOWS)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment