Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

simplelink: wifi: avoid re-declaring pthread_self() #44

Merged

Conversation

cfriedt
Copy link
Member

@cfriedt cfriedt commented Oct 30, 2022

The normative spec says this returns pthread_t, not void *.

It's probably better to simply #include <pthread.h> outside of this file explicitly (due to current non-standard prefixed path in Zerphy) than to re-declare it with a potentially conflicting signature.

extern void * pthread_self(void);
extern pthread_t pthread_self(void);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will not work since this header does not include any headers that would provide the typedef for pthread_t.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On the contrary - it does work:

twister -i -p cc3220sf_launchxl -s samples/net/sockets/http_get/sample.net.sockets.http_get.offload.simplelink
Renaming output directory to /Users/cfriedt/workspace/zephyrproject/zephyr/twister-out.21
INFO    - Using Ninja..
INFO    - Zephyr version: zephyr-v3.2.0-987-gad7ffc405d9a
INFO    - Using 'zephyr' toolchain.
INFO    - Building initial testsuite list...
INFO    - Writing JSON report /Users/cfriedt/workspace/zephyrproject/zephyr/twister-out/testplan.json
INFO    - JOBS: 8
INFO    - Adding tasks to the queue...
INFO    - Added initial list of jobs to queue
INFO    - Total complete:    1/   1  100%  skipped:    0, failed:    0
INFO    - 1 test scenarios (1 test instances) selected, 0 configurations skipped (0 by static filter, 0 at runtime).
INFO    - 1 of 1 test configurations passed (100.00%), 0 failed, 0 skipped with 0 warnings in 35.05 seconds
INFO    - In total 0 test cases were executed, 1 skipped on 1 out of total 510 platforms (0.20%)
INFO    - 0 test configurations executed on platforms, 1 test configurations were only built.
INFO    - Saving reports...
INFO    - Writing JSON report /Users/cfriedt/workspace/zephyrproject/zephyr/twister-out/twister.json
INFO    - Writing xunit report /Users/cfriedt/workspace/zephyrproject/zephyr/twister-out/twister.xml...
INFO    - Writing xunit report /Users/cfriedt/workspace/zephyrproject/zephyr/twister-out/twister_report.xml...
INFO    - Run completed

See also passing CI
zephyrproject-rtos/zephyr#51784

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

then that is purely by luck because some C files that include this header happen to include POSIX headers.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

then that is purely by luck because some C files that include this header happen to include POSIX headers.

also that brings the question of, why is this pthread_self forward declaration necessary if the POSIX headers can be included in this scope?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also that brings the question of, why is this pthread_self forward declaration necessary if the POSIX headers can be included in this scope?

As you are aware, Zephyr POSIX headers cannot be portably included in this scope. That is the issue fixed by zephyrproject-rtos/zephyr#51771, which now indirectly depends on this PR.

Let's not make this a chicken-egg problem please.

Copy link
Member

@stephanosio stephanosio Oct 30, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

until then, this header should be including zephyr/posix/pthread.h (assuming pthread.h is include-able in this scope).

Copy link
Member

@stephanosio stephanosio Oct 30, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in fact, I just removed this extern pthread_t pthread_self(void); entirely, and it works, meaning pthread.h is already included somewhere.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like pthread.h is included here:

#include <zephyr/posix/pthread.h>

@stephanosio
Copy link
Member

stephanosio commented Oct 30, 2022

also why is this HAL using the pthread functions?

#define sl_LockObjLock(pLockObj,Timeout) pthread_mutex_lock(pLockObj)

A proper port ought to be using the native Zephyr APIs here.

@cfriedt
Copy link
Member Author

cfriedt commented Oct 30, 2022

also why is this HAL using the pthread functions?

#define sl_LockObjLock(pLockObj,Timeout) pthread_mutex_lock(pLockObj)

A proper port ought to be using the native Zephyr APIs here.

@stephanosio - that's a great question to ask TI. However, POSIX is not evil - it's actually a great interface to use for portable code to different operating systems (Portable Operating System Interface)

@cfriedt cfriedt dismissed stephanosio’s stale review October 30, 2022 13:23

wrong assumptions used

Copy link
Member

@stephanosio stephanosio left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the assumption is not wrong.

a header must include the headers that provides the dependencies it makes use of.

@stephanosio
Copy link
Member

@stephanosio - that's a great question to ask TI

no, when adding support for this chipset, the porting layer should have been updated to use the Zephyr native API. In that sense, this port is incomplete.

@cfriedt
Copy link
Member Author

cfriedt commented Oct 30, 2022

@stephanosio - that is WELL beyond the scope of this change. Feel free to create an issue though.

@stephanosio
Copy link
Member

@stephanosio - that is WELL beyond the scope of this change. Feel free to create an issue though.

agreed. just pointing out that there is something fishy about this port.

@stephanosio
Copy link
Member

However, POSIX is not evil - it's actually a great interface to use for portable code to different operating systems (Portable Operating System Interface)

POSIX is not evil, but as long as Zephyr's native API is not POSIX, it will come with the added footprint, which is evil.

@cfriedt cfriedt force-pushed the use-correct-pthread-self-signature branch from ea84987 to 5802cd2 Compare October 30, 2022 23:31
The normative spec says this returns `pthread_t`, not `void *`.
It's probably better to simply `#include <pthread.h>` outside
of this file explicitly (due to current non-standard prefixed
path in Zerphy) than to re-declare it with a potentially
conflicting signature.

Signed-off-by: Chris Friedt <[email protected]>
@cfriedt cfriedt force-pushed the use-correct-pthread-self-signature branch from 5802cd2 to 34ef193 Compare October 30, 2022 23:53
@cfriedt cfriedt changed the title simplelink: wifi: use correct signature for pthread_self() simplelink: wifi: avoid re-declaring pthread_self() Oct 30, 2022
@cfriedt
Copy link
Member Author

cfriedt commented Oct 30, 2022

@stephanosio - removed the conflicting declaration

@cfriedt
Copy link
Member Author

cfriedt commented Oct 31, 2022

@stephanosio - does this look OK now? Please ack if so.

@stephanosio
Copy link
Member

@stephanosio - does this look OK now? Please ack if so.

yes, but can you please update the Zephyr-side PR so CI can run on it?

@cfriedt
Copy link
Member Author

cfriedt commented Oct 31, 2022

@stephanosio - does this look OK now? Please ack if so.

yes, but can you please update the Zephyr-side PR so CI can run on it?

There isn't anything to update until this PR is merged.

@stephanosio
Copy link
Member

There isn't anything to update until this PR is merged.

did zephyrproject-rtos/zephyr#51784 run with the latest iteration of this PR? I just want to make sure that nothing else broke because of the latest change.

@cfriedt
Copy link
Member Author

cfriedt commented Oct 31, 2022

@stephanosio I just force-pushed again to be sure

@cfriedt cfriedt merged commit a5ffc6d into zephyrproject-rtos:master Oct 31, 2022
@cfriedt cfriedt deleted the use-correct-pthread-self-signature branch October 31, 2022 21:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants