PengZheng commented on code in PR #536: URL: https://github.com/apache/celix/pull/536#discussion_r1184479054
########## 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 the thread local storage allocation will be deferred to first usage. I used to think that way. Back in 2018, Zhengbao Xu used very large thread local storage in a static library, which is linked into a large application of hundreds threads. Then we found that extra memory consumption is nb_threads*sizeof(tls). But my memory may not be accurate. @xuzhenbao It's a good idea that we do some investigation on this. -- 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