/*
 * Licensed 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.
 */

#ifndef java_lang_Thread_H
#define java_lang_Thread_H

#import <pthread.h>

@class JavaLangThread;

CF_EXTERN_C_BEGIN

pthread_key_t java_thread_key;
pthread_once_t java_thread_key_init_once;

void initJavaThreadKeyOnce();
JavaLangThread *getCurrentJavaThreadOrNull();

CF_EXTERN_C_END

#endif  // java_lang_Thread_H

/*
 * Licensed 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.
 */

#ifndef java_lang_Thread_H
#define java_lang_Thread_H

#import <pthread.h>

@class JavaLangThread;

CF_EXTERN_C_BEGIN

extern pthread_key_t java_thread_key;
extern pthread_once_t java_thread_key_init_once;

void initJavaThreadKeyOnce();
JavaLangThread *getCurrentJavaThreadOrNull();

CF_EXTERN_C_END

#endif  // java_lang_Thread_H

Fix unintentional tentative definitions that result in duplicate symbol definitions when building with -fno-common
Fix unintentional tentative definitions that result in duplicate symbol definitions when building with -fno-common

This primarily consists of adding missing `extern`s in front of declarations of global variables, and `typedef` in front of some `NS_ENUM`s.

-fno-common is being turned on by default with Clang 11. This fix is a preemptive measure to ensure code will compile when Clang 11 is shipped in a future Xcode update.

In C, global variables that are defined without an initializer are known as tentative definitions. These are distinct from declarations of global variables, which are preceeded by the `extern` keyword.

For performance and correctness reasons, Clang is changing their handling of tentative definitions. Almost all tentative definitions are unintentional omissions of `extern`, rather than an intentional decision by the code author, which can result in subtle bugs that are hard to pin down.

Historically, Clang has placed tentative definitions in the __DATA,__common section. The linker then allows non-tentative definitions to override any tentative definitions, and coalesces all tentative definitions of a single symbol into a single tentative definition. This meant that having multiple tentative definitions would not produce a linker error about duplicate symbol definitions, nor would having both a normal and tentative definition.

With the -fno-common flag, Clang will instead place both tentative and normal definitions in the __DATA,__bss section, which will result in duplicate symbol definition errors from the linker if multiple tentative definitions and/or normal definitions are present in different object files.

PiperOrigin-RevId: 305885508
