Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
E
EtherBone Core
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor 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
Projects
EtherBone Core
Commits
dc234967
Commit
dc234967
authored
13 years ago
by
Wesley W. Terpstra
Browse files
Options
Downloads
Patches
Plain Diff
Eliminate dependency on non-portable alloca.
parent
665baa15
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
api/glue/sdwb.c
+31
-5
31 additions, 5 deletions
api/glue/sdwb.c
with
31 additions
and
5 deletions
api/glue/sdwb.c
+
31
−
5
View file @
dc234967
...
...
@@ -34,7 +34,6 @@
#include
"../memory/memory.h"
#include
<string.h>
#include
<alloca.h>
static
eb_data_t
eb_sdwb_extract
(
void
*
data
,
eb_width_t
width
,
eb_address_t
addr
)
{
eb_data_t
out
;
...
...
@@ -200,13 +199,34 @@ static void eb_sdwb_decode(struct eb_sdwb_scan* scan, uint8_t* buf, eb_operation
(
*
cb
)(
data
,
sdwb
,
EB_OK
);
}
/* We allocate buffer on the stack to hack around missing alloca */
#define EB_SDWB_DECODE(x) \
static void eb_sdwb_decode##x(struct eb_sdwb_scan* scan, eb_operation_t ops) { \
union { \
struct { \
struct sdwb_header header; \
struct sdwb_id_block id_block; \
struct sdwb_device_descriptor device_descriptor[x]; \
} s; \
uint8_t bytes[1]; \
} sdwb; \
return eb_sdwb_decode(scan, &sdwb.bytes[0], ops); \
}
EB_SDWB_DECODE
(
4
)
EB_SDWB_DECODE
(
8
)
EB_SDWB_DECODE
(
16
)
EB_SDWB_DECODE
(
32
)
EB_SDWB_DECODE
(
64
)
EB_SDWB_DECODE
(
128
)
EB_SDWB_DECODE
(
256
)
static
void
eb_sdwb_got_all
(
eb_user_data_t
mydata
,
eb_operation_t
ops
,
eb_status_t
status
)
{
struct
eb_sdwb_scan
*
scan
;
eb_sdwb_scan_t
scanp
;
eb_user_data_t
data
;
sdwb_callback_t
cb
;
uint16_t
devices
;
uint8_t
*
buf
;
scanp
=
(
eb_sdwb_scan_t
)(
uintptr_t
)
mydata
;
scan
=
EB_SDWB_SCAN
(
scanp
);
...
...
@@ -220,9 +240,15 @@ static void eb_sdwb_got_all(eb_user_data_t mydata, eb_operation_t ops, eb_status
return
;
}
/* Use trick !!! */
buf
=
alloca
(
32
+
32
+
80
*
devices
);
eb_sdwb_decode
(
scan
,
buf
,
ops
);
if
(
devices
<
4
)
eb_sdwb_decode4
(
scan
,
ops
);
else
if
(
devices
<
8
)
eb_sdwb_decode8
(
scan
,
ops
);
else
if
(
devices
<
16
)
eb_sdwb_decode16
(
scan
,
ops
);
else
if
(
devices
<
32
)
eb_sdwb_decode32
(
scan
,
ops
);
else
if
(
devices
<
64
)
eb_sdwb_decode64
(
scan
,
ops
);
else
if
(
devices
<
128
)
eb_sdwb_decode128
(
scan
,
ops
);
else
if
(
devices
<
256
)
eb_sdwb_decode256
(
scan
,
ops
);
else
(
*
cb
)(
data
,
0
,
EB_OOM
);
eb_free_sdwb_scan
(
scanp
);
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
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