patacongo commented on a change in pull request #3170:
URL: https://github.com/apache/incubator-nuttx/pull/3170#discussion_r600764966



##########
File path: libs/libc/unistd/lib_getoptvars.c
##########
@@ -0,0 +1,153 @@
+/****************************************************************************
+ * libs/libc/unistd/lib_getoptvars.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 <unistd.h>
+#include <pthread.h>
+
+#include "unistd.h"
+#include "libc.h"
+
+/****************************************************************************
+ * Pre-processor Definitions
+ ****************************************************************************/
+
+#define INVALID_KEY    CONFIG_TLS_NELEM
+#define VALID_KEY(key) ((key) >= 0 && key < CONFIG_TLS_NELEM)
+
+/* Configuration.  Currently no thread-specific data destructors. */
+
+#undef  HAVE_DESTRUCTOR
+#define HAVE_CLEANUP   1
+#define HAVE_TLSVARS   1
+
+/* Check if we have some way to avoid a memory leak */
+
+#if defined(CONFIG_DISABLE_PTHREAD) || !defined(CONFIG_PTHREAD_CLEANUP)
+#  undef HAVE_CLEANUP
+#endif
+
+/* Don't use TLS if we cannot avoid the memory leak or if TLS is disabled */
+
+#if (!defined(HAVE_DESTRUCTOR) && !defined(HAVE_CLEANUP)) || \
+    CONFIG_TLS_NELEM == 0
+#  undef HAVE_TLSVARS
+#endif
+

Review comment:
       The above options CONFIG_DISABLE_PTHREAD and CONFIG_PTHREAD_CLEANUP 
options are a nuisance.  What do people think about just removing this?  
Pthreads are quite large and this will impact small platforms.
   
   Another option would be to support pthread_cleanup_push() even when pthreads 
are disabled.. similar to how pthread specific data is enabled now.
   
   The pthread specific data destructor is not currently implemented.  
@antmerlino started this some months back (along with correct some other 
issues) on the pthread_user thread but we lost steam on that one.
   
   If the destructor were implemented, it will automatically callback to a 
pthread data destructor when the pthread exits.




-- 
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:
[email protected]


Reply via email to