Index: src/OFSystemInfo.h ================================================================== --- src/OFSystemInfo.h +++ src/OFSystemInfo.h @@ -38,10 +38,11 @@ # ifdef OF_HAVE_FILES @property (class, readonly, nullable, nonatomic) OFString *userDataPath; @property (class, readonly, nullable, nonatomic) OFString *userConfigPath; # endif @property (class, readonly, nullable, nonatomic) OFString *CPUVendor; +@property (class, readonly, nullable, nonatomic) OFString *CPUModel; # if defined(OF_X86_64) || defined(OF_X86) || defined(DOXYGEN) @property (class, readonly, nonatomic) bool supportsMMX; @property (class, readonly, nonatomic) bool supportsSSE; @property (class, readonly, nonatomic) bool supportsSSE2; @property (class, readonly, nonatomic) bool supportsSSE3; @@ -144,10 +145,19 @@ * * @return The vendor of the CPU */ + (nullable OFString *)CPUVendor; +/*! + * @brief Returns the model of the CPU. + * + * If the model could not be determined, `nil` is returned instead. + * + * @return The model of the CPU + */ ++ (nullable OFString *)CPUModel; + #if defined(OF_X86_64) || defined(OF_X86) || defined(DOXYGEN) /*! * @brief Returns whether the CPU supports MMX. * * @note This method is only available on x86 and x86_64. Index: src/OFSystemInfo.m ================================================================== --- src/OFSystemInfo.m +++ src/OFSystemInfo.m @@ -26,11 +26,11 @@ #include "platform.h" #ifdef HAVE_SYS_UTSNAME_H # include #endif -#ifdef OF_MACOS +#if defined(OF_MACOS) || defined(OF_NETBSD) # include #endif #if defined(OF_AMIGAOS4) # define __USE_INLINE__ @@ -568,10 +568,42 @@ return [OFString stringWithCString: buffer encoding: OF_STRING_ENCODING_ASCII length: 12]; #else + return nil; +#endif +} + ++ (OFString *)CPUModel +{ +#if defined(OF_MACOS) || defined(OF_NETBSD) + char value[256]; + size_t length = sizeof(value); + +# if defined(OF_MACOS) + if (sysctlbyname("machdep.cpu.brand_string", +# elif defined(OF_NETBSD) + if (sysctlbyname("machdep.cpu_brand", +# endif + &value, &length, NULL, 0) != 0) + return nil; + + return [OFString stringWithCString: value + encoding: OF_STRING_ENCODING_ASCII]; +#elif defined(OF_AMIGAOS4) + CONST_STRPTR model, version; + + GetCPUInfoTags(GCIT_ModelString, &model, + GCIT_VersionString, &version, TAG_END); + + if (version != NULL) + return [OFString stringWithFormat: @"%s V%s", model, version]; + else + return [OFString stringWithCString: model + encoding: OF_STRING_ENCODING_ASCII]; +#else return nil; #endif } #if defined(OF_X86_64) || defined(OF_X86) Index: tests/OFSystemInfoTests.m ================================================================== --- tests/OFSystemInfoTests.m +++ tests/OFSystemInfoTests.m @@ -62,10 +62,12 @@ } PRINT(GREEN, @"User data path: %@", userDataPath); #endif PRINT(GREEN, @"CPU vendor: %@", [OFSystemInfo CPUVendor]); + + PRINT(GREEN, @"CPU model: %@", [OFSystemInfo CPUModel]); #if defined(OF_X86_64) || defined(OF_X86) PRINT(GREEN, @"Supports MMX: %d", [OFSystemInfo supportsMMX]); PRINT(GREEN, @"Supports SSE: %d", [OFSystemInfo supportsSSE]);