1
0
Fork 0
forked from nuttx/nuttx-update

libc: Add getprogname function

defined here:
https://www.freebsd.org/cgi/man.cgi?query=getprogname&sektion=3

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
This commit is contained in:
Xiang Xiao 2021-11-29 12:46:00 +08:00 committed by Xiang Xiao
parent d05b9a9c79
commit ed1e4ddfa7
3 changed files with 49 additions and 1 deletions

View file

@ -265,6 +265,10 @@ FAR void *bsearch(FAR const void *key, FAR const void *base, size_t nel,
size_t width, CODE int (*compar)(FAR const void *,
FAR const void *));
/* Current program name manipulation */
FAR const char *getprogname(void);
#undef EXTERN
#if defined(__cplusplus)
}

View file

@ -20,7 +20,7 @@
# Add the stdlib C files to the build
CSRCS += lib_abs.c lib_abort.c lib_atof.c lib_atoi.c
CSRCS += lib_abs.c lib_abort.c lib_atof.c lib_atoi.c lib_getprogname.c
CSRCS += lib_atol.c lib_atoll.c lib_div.c lib_ldiv.c lib_lldiv.c lib_Exit.c
CSRCS += lib_itoa.c lib_labs.c lib_llabs.c lib_realpath.c lib_bsearch.c
CSRCS += lib_rand.c lib_qsort.c lib_srand.c lib_strtol.c

View file

@ -0,0 +1,44 @@
/****************************************************************************
* libs/libc/stdlib/lib_getprogname.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 <stdlib.h>
#include <nuttx/tls.h>
/****************************************************************************
* Public Functions
****************************************************************************/
/****************************************************************************
* Name: getprogname
****************************************************************************/
FAR const char *getprogname(void)
{
FAR struct task_info_s *info;
info = task_get_info();
return info->argv[0];
}