Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
pike
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
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
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
pikelang
pike
Commits
a9388aea
Commit
a9388aea
authored
26 years ago
by
Henrik (Grubba) Grubbström
Browse files
Options
Downloads
Patches
Plain Diff
Added C-stack alignment code.
Now aligns the initial C stack on a 64KB boundary. Rev: src/main.c:1.58
parent
e0aa66db
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/main.c
+33
-7
33 additions, 7 deletions
src/main.c
with
33 additions
and
7 deletions
src/main.c
+
33
−
7
View file @
a9388aea
...
...
@@ -4,7 +4,7 @@
||| See the files COPYING and DISCLAIMER for more information.
\*/
#include
"global.h"
RCSID
(
"$Id: main.c,v 1.5
7
1998/0
8/10 23:33:30 h
ubb
e
Exp $"
);
RCSID
(
"$Id: main.c,v 1.5
8
1998/0
9/02 01:05:45 gr
ubb
a
Exp $"
);
#include
"fdlib.h"
#include
"backend.h"
#include
"module.h"
...
...
@@ -323,6 +323,24 @@ int dbm_main(int argc, char **argv)
#define RLIMIT_NOFILE RLIMIT_OFILE
#endif
stack_top
=
(
char
*
)
&
argv
;
/* Adjust for anything already pushed on the stack.
* We align on a 64 KB boundary.
* Thus we at worst, lose 64 KB stack.
*
* We have to do it this way since some compilers don't like
* & and | on pointers, and casting to an integer type is
* too unsafe (consider 64-bit systems).
*/
#if STACK_DIRECTION < 0
/* Equvivalent with |= 0xffff */
stack_top
+=
(
~
((
unsigned
long
)
stack_top
))
&
0xffff
;
#else
/* STACK_DIRECTION >= 0 */
/* Equvivalent with &= ~0xffff */
stack_top
-=
(
((
unsigned
long
)
stack_top
))
&
0xffff
;
#endif
/* STACK_DIRECTION < 0 */
#if defined(HAVE_GETRLIMIT) && defined(RLIMIT_STACK)
{
struct
rlimit
lim
;
...
...
@@ -332,14 +350,22 @@ int dbm_main(int argc, char **argv)
if
(
lim
.
rlim_cur
==
RLIM_INFINITY
)
lim
.
rlim_cur
=
1024
*
1024
*
128
;
#endif
stack_top
=
((
char
*
)
&
argv
)
+
STACK_DIRECTION
*
(
lim
.
rlim_cur
-
8192
*
sizeof
(
char
*
));
}
}
#else
stack_top
=
((
char
*
)
&
argv
)
+
STACK_DIRECTION
*
(
1024
*
1024
*
128
-
8192
*
sizeof
(
char
*
));
#endif
stack_top
+=
STACK_DIRECTION
*
(
lim
.
rlim_cur
-
8192
*
sizeof
(
char
*
));
#ifdef STACK_DEBUG
fprintf
(
stderr
,
"1: C-stack: 0x%08p - 0x%08p, direction:%d
\n
"
,
&
argv
,
stack_top
,
STACK_DIRECTION
);
#endif
/* STACK_DEBUG */
}
}
#else
/* !HAVE_GETRLIMIT || !RLIMIT_STACK */
/* 128 MB seems a bit extreme, most OS's seem to have their limit at ~8MB */
stack_top
+=
STACK_DIRECTION
*
(
1024
*
1024
*
128
-
8192
*
sizeof
(
char
*
));
#ifdef STACK_DEBUG
fprintf
(
stderr
,
"2: C-stack: 0x%08p - 0x%08p, direction:%d
\n
"
,
&
argv
,
stack_top
,
STACK_DIRECTION
);
#endif
/* STACK_DEBUG */
#endif
/* HAVE_GETRLIMIT && RLIMIT_STACK */
#if defined(HAVE_SETRLIMIT) && defined(RLIMIT_NOFILE)
{
...
...
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