2012-11-10 17:06:01 +01:00
|
|
|
/****************************************************************************
|
2018-05-29 21:21:26 +02:00
|
|
|
* libs/libc/pthread/pthread_attr_init.c
|
2012-11-10 17:06:01 +01:00
|
|
|
*
|
2021-03-02 15:54:21 +01:00
|
|
|
* 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
|
2012-11-10 17:06:01 +01:00
|
|
|
*
|
2021-03-02 15:54:21 +01:00
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
2012-11-10 17:06:01 +01:00
|
|
|
*
|
2021-03-02 15:54:21 +01:00
|
|
|
* 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.
|
2012-11-10 17:06:01 +01:00
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Included Files
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
#include <nuttx/config.h>
|
|
|
|
|
|
|
|
#include <pthread.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <debug.h>
|
|
|
|
#include <errno.h>
|
|
|
|
|
|
|
|
#include <nuttx/pthread.h>
|
|
|
|
|
|
|
|
/****************************************************************************
|
2015-10-03 00:30:35 +02:00
|
|
|
* Public Data
|
2012-11-10 17:06:01 +01:00
|
|
|
****************************************************************************/
|
|
|
|
|
2014-09-07 18:46:58 +02:00
|
|
|
/* Default pthread attributes (see include/nuttx/pthread.h). When configured
|
2012-11-10 17:06:01 +01:00
|
|
|
* to build separate kernel- and user-address spaces, this global is
|
|
|
|
* duplicated in each address spaced. This copy can only be shared within
|
2014-04-13 22:32:20 +02:00
|
|
|
* the user address space.
|
2012-11-10 17:06:01 +01:00
|
|
|
*/
|
|
|
|
|
2020-04-29 21:21:23 +02:00
|
|
|
#if !defined(CONFIG_BUILD_FLAT) && !defined(__KERNEL__)
|
2014-09-07 18:46:58 +02:00
|
|
|
const pthread_attr_t g_default_pthread_attr = PTHREAD_ATTR_INITIALIZER;
|
2012-11-10 17:06:01 +01:00
|
|
|
#endif
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Public Functions
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
/****************************************************************************
|
2017-04-22 00:33:14 +02:00
|
|
|
* Name: pthread_attr_init
|
2012-11-10 17:06:01 +01:00
|
|
|
*
|
|
|
|
* Description:
|
|
|
|
* Initializes a thread attributes object (attr) with
|
|
|
|
* default values for all of the individual attributes
|
|
|
|
* used by a given implementation.
|
|
|
|
*
|
2018-03-13 16:52:27 +01:00
|
|
|
* Input Parameters:
|
2012-11-10 17:06:01 +01:00
|
|
|
* attr
|
|
|
|
*
|
2018-02-01 17:00:02 +01:00
|
|
|
* Returned Value:
|
2012-11-10 17:06:01 +01:00
|
|
|
* 0 on success, otherwise an error number
|
|
|
|
*
|
|
|
|
* Assumptions:
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
int pthread_attr_init(FAR pthread_attr_t *attr)
|
|
|
|
{
|
|
|
|
int ret = OK;
|
|
|
|
|
2022-06-30 19:33:04 +02:00
|
|
|
linfo("attr=%p\n", attr);
|
2012-11-10 17:06:01 +01:00
|
|
|
if (!attr)
|
|
|
|
{
|
|
|
|
ret = ENOMEM;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* Set the child thread priority to be the default
|
|
|
|
* priority. Set the child stack size to some arbitrary
|
|
|
|
* default value.
|
|
|
|
*/
|
|
|
|
|
|
|
|
memcpy(attr, &g_default_pthread_attr, sizeof(pthread_attr_t));
|
|
|
|
}
|
|
|
|
|
2016-06-12 19:11:57 +02:00
|
|
|
linfo("Returning %d\n", ret);
|
2012-11-10 17:06:01 +01:00
|
|
|
return ret;
|
|
|
|
}
|