You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by GitBox <gi...@apache.org> on 2020/08/14 04:25:36 UTC
[GitHub] [incubator-nuttx] anchao opened a new pull request #1580: libc/pthread: Implement pthread_condattr_[g|s]etclock
anchao opened a new pull request #1580:
URL: https://github.com/apache/incubator-nuttx/pull/1580
## Summary
libc/pthread: Implement pthread_condattr_[g|s]etclock
Reference:
https: //pubs.opengroup.org/onlinepubs/009695399/functions/pthread_condattr_setclock.html
Change-Id: I19c15d5f219fcf28dbfeb2e5a1e3fc7b38ba2259
Signed-off-by: chao.an <an...@xiaomi.com>
## Impact
pthread_condattr_setclock
pthread_cond_init
pthread_cond_timedwait
pthread_condattr_getclock
pthread_condattr_init
## Testing
API test
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [incubator-nuttx] Ouss4 commented on a change in pull request #1580: libc/pthread: Implement pthread_condattr_[g|s]etclock
Posted by GitBox <gi...@apache.org>.
Ouss4 commented on a change in pull request #1580:
URL: https://github.com/apache/incubator-nuttx/pull/1580#discussion_r471175408
##########
File path: libs/libc/pthread/pthread_condattr_setclock.c
##########
@@ -0,0 +1,61 @@
+/****************************************************************************
+ * libs/libc/pthread/pthread_condattr_setclock.c
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership. The
+ * ASF licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the
+ * License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+
+#include <pthread.h>
+#include <errno.h>
+
+/****************************************************************************
+ * Public Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: pthread_condattr_setclock
+ *
+ * Description:
+ * set the clock selection condition variable attribute
+ *
+ * Input Parameters:
+ * None
+ *
+ * Returned Value:
+ * If successful, the pthread_condattr_setclock() function shall
+ * return zero; otherwise, an error number shall be returned to
+ * indicate the error.
+ *
+ ****************************************************************************/
+
+int pthread_condattr_setclock(FAR pthread_condattr_t *attr,
+ clockid_t clock_id)
+{
+ if (!attr)
+ {
+ return EINVAL;
+ }
+
+ attr->clockid = clock_id;
Review comment:
Should we check if the `clock_id` is within a valid range? POSIX says that `EINVAL` should be returned if clock_id is invalid. We only have `CLOCK_REALTIME` and `CLOCK_MONOTONIC`.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [incubator-nuttx] anchao commented on a change in pull request #1580: libc/pthread: Implement pthread_condattr_[g|s]etclock
Posted by GitBox <gi...@apache.org>.
anchao commented on a change in pull request #1580:
URL: https://github.com/apache/incubator-nuttx/pull/1580#discussion_r471210819
##########
File path: libs/libc/pthread/pthread_condattr_setclock.c
##########
@@ -0,0 +1,61 @@
+/****************************************************************************
+ * libs/libc/pthread/pthread_condattr_setclock.c
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership. The
+ * ASF licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the
+ * License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+
+#include <pthread.h>
+#include <errno.h>
+
+/****************************************************************************
+ * Public Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: pthread_condattr_setclock
+ *
+ * Description:
+ * set the clock selection condition variable attribute
+ *
+ * Input Parameters:
+ * None
+ *
+ * Returned Value:
+ * If successful, the pthread_condattr_setclock() function shall
+ * return zero; otherwise, an error number shall be returned to
+ * indicate the error.
+ *
+ ****************************************************************************/
+
+int pthread_condattr_setclock(FAR pthread_condattr_t *attr,
+ clockid_t clock_id)
+{
+ if (!attr)
+ {
+ return EINVAL;
+ }
+
+ attr->clockid = clock_id;
Review comment:
Got, I added the clock range check in pthread_condattr_setclock(2)
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [incubator-nuttx] Ouss4 merged pull request #1580: libc/pthread: Implement pthread_condattr_[g|s]etclock
Posted by GitBox <gi...@apache.org>.
Ouss4 merged pull request #1580:
URL: https://github.com/apache/incubator-nuttx/pull/1580
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org