mirror of
https://git.in.rschanz.org/ryan77627/guix.git
synced 2025-01-12 14:16:55 -05:00
guix: cpu: Add support for reading armhf/aarch64 CPUs.
* guix/cpu.scm (current-cpu): Set flags at the beginning of the loop. Read from '/proc/cpuinfo' until the end of the file. Add match options for discovering armhf/aarch64 cpu configurations.
This commit is contained in:
parent
edf86bacf2
commit
41ed6db81e
1 changed files with 29 additions and 9 deletions
38
guix/cpu.scm
38
guix/cpu.scm
|
@ -62,31 +62,51 @@ (define (prefix? prefix)
|
||||||
(lambda (port)
|
(lambda (port)
|
||||||
(let loop ((vendor #f)
|
(let loop ((vendor #f)
|
||||||
(family #f)
|
(family #f)
|
||||||
(model #f))
|
(model #f)
|
||||||
|
(flags (set)))
|
||||||
(match (read-line port)
|
(match (read-line port)
|
||||||
((? eof-object?)
|
((? eof-object?)
|
||||||
#f)
|
(cpu (utsname:machine (uname))
|
||||||
|
vendor family model flags))
|
||||||
|
;; vendor for x86_64 and i686
|
||||||
((? (prefix? "vendor_id") str)
|
((? (prefix? "vendor_id") str)
|
||||||
(match (string-tokenize str)
|
(match (string-tokenize str)
|
||||||
(("vendor_id" ":" vendor)
|
(("vendor_id" ":" vendor)
|
||||||
(loop vendor family model))))
|
(loop vendor family model flags))))
|
||||||
|
;; vendor for aarch64 and armhf
|
||||||
|
((? (prefix? "CPU implementer") str)
|
||||||
|
(match (string-tokenize str)
|
||||||
|
(("CPU" "implementer" ":" vendor)
|
||||||
|
(loop vendor family model flags))))
|
||||||
|
;; family for x86_64 and i686
|
||||||
((? (prefix? "cpu family") str)
|
((? (prefix? "cpu family") str)
|
||||||
(match (string-tokenize str)
|
(match (string-tokenize str)
|
||||||
(("cpu" "family" ":" family)
|
(("cpu" "family" ":" family)
|
||||||
(loop vendor (string->number family) model))))
|
(loop vendor (string->number family) model flags))))
|
||||||
|
;; model for x86_64 and i686
|
||||||
((? (prefix? "model") str)
|
((? (prefix? "model") str)
|
||||||
(match (string-tokenize str)
|
(match (string-tokenize str)
|
||||||
(("model" ":" model)
|
(("model" ":" model)
|
||||||
(loop vendor family (string->number model)))
|
(loop vendor family (string->number model) flags))
|
||||||
(_
|
(_
|
||||||
(loop vendor family model))))
|
(loop vendor family model flags))))
|
||||||
|
;; model for aarch64 and armhf
|
||||||
|
((? (prefix? "CPU part") str)
|
||||||
|
(match (string-tokenize str)
|
||||||
|
(("CPU" "part" ":" model)
|
||||||
|
(loop vendor family (string->number (string-drop model 2) 16) flags))))
|
||||||
|
;; flags for x86_64 and i686
|
||||||
((? (prefix? "flags") str)
|
((? (prefix? "flags") str)
|
||||||
(match (string-tokenize str)
|
(match (string-tokenize str)
|
||||||
(("flags" ":" flags ...)
|
(("flags" ":" flags ...)
|
||||||
(cpu (utsname:machine (uname))
|
(loop vendor family model (list->set flags)))))
|
||||||
vendor family model (list->set flags)))))
|
;; flags for aarch64 and armhf
|
||||||
|
((? (prefix? "Features") str)
|
||||||
|
(match (string-tokenize str)
|
||||||
|
(("Features" ":" flags ...)
|
||||||
|
(loop vendor family model (list->set flags)))))
|
||||||
(_
|
(_
|
||||||
(loop vendor family model))))))))
|
(loop vendor family model flags))))))))
|
||||||
|
|
||||||
(define (cpu->gcc-architecture cpu)
|
(define (cpu->gcc-architecture cpu)
|
||||||
"Return the architecture name, suitable for GCC's '-march' flag, that
|
"Return the architecture name, suitable for GCC's '-march' flag, that
|
||||||
|
|
Loading…
Reference in a new issue