pnoltes commented on code in PR #536:
URL: https://github.com/apache/celix/pull/536#discussion_r1184131867


##########
libs/utils/src/celix_err.c:
##########
@@ -0,0 +1,166 @@
+/*
+ * 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.
+ */
+
+#include "celix_err.h"
+
+#include <stdarg.h>
+#include <stdio.h>
+#include <string.h>
+
+#ifndef CELIX_ERR_USE_THREAD_LOCAL
+#include <stdlib.h>
+#include "celix_threads.h"
+#endif
+
+typedef struct celix_err {
+    char buffer[CELIX_ERR_BUFFER_SIZE];
+    size_t pos;
+} celix_err_t;
+
+#ifdef CELIX_ERR_USE_THREAD_LOCAL
+
+__thread celix_err_t celix_err_tssErr = { .buffer = {0}, .pos = 0 };

Review Comment:
   I think not, but to be honest I am not sure.
   
   Reading 
https://gcc.gnu.org/onlinedocs/gcc-12.2.0/gcc/Thread-Local.html#Thread-Local 
and - parts of - 
   https://www.akkadia.org/drepper/tls.pdf (chapter 3)
   
   I think the thread local storage allocation will be deferred to first usage. 
   
   > In addition the run-time support should avoid creating the thread-local 
storage if
   it is not necessary. For instance, a loaded module might only be used by one 
thread
   of the many which make up the process. It would be a waste of memory and 
time to
   allocate the storage for all threads. A lazy method is wanted. 
   
   > Using the tls get addr function has the additional advantage to allow 
imple-
   menting the dynamic model where the allocation of the TLS blocks is deferred 
to the
   first use. 
   
   But I will investigate this more thoroughly.



-- 
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.

To unsubscribe, e-mail: dev-unsubscr...@celix.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to