Skip to content

Instantly share code, notes, and snippets.

@jgouly
jgouly / vt.md
Created September 15, 2020 23:39
Linux: Ctr-Alt-F<N> switches between virtual terminals/consoles, but how?

Linux: Ctr-Alt-F<N> switches between virtual terminals/consoles, but how?

I remembered the chvt (change foreground virtual terminal) command, so that seems like a good place to start. I looked at BusyBox's implementation in console-tools/chvt.c, hoping that it would be small enough to skim through. At 33 lines, with only 9 lines containing code I wasn't disappointed.

The call to console_make_active looks interesting. console_make_active can be found in libbb/get_console.c:

diff --git a/cranelift-codegen/src/timing.rs b/cranelift-codegen/src/timing.rs
index 16f729f7..51d500fe 100644
--- a/cranelift-codegen/src/timing.rs
+++ b/cranelift-codegen/src/timing.rs
@@ -189,7 +189,7 @@ mod details {
let prev = CURRENT_PASS.with(|p| p.replace(pass));
debug!("timing: Starting {}, (during {})", pass, prev);
TimingToken {
- start: Instant::now(),
+ start: unsafe { std::mem::transmute(0u128) },//Instant::now(),
void handle_action(action_code a) {
bool should_process = true;
if (user_hook) {
should_process = user_hook(a);
}
if (should_process) {
switch(a) {
case NORMAL_KEY: ...
}
}
; ModuleID = 'rust-out.0.rs'
target datalayout = "e-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"
; Function Attrs: nounwind readnone uwtable
define i64 @"_ZN14_$LP$$RP$.Many6switch20h6ca796108d9da36e9aaE"({}* noalias nocapture readonly, i64) unnamed_addr #0 {
entry-block:
%2 = icmp eq i64 %1, -4643972648086929078
br i1 %2, label %e1, label %else-block
;; Original from: http://is.gd/WxkPFL
; ModuleID = 'rust-out.0.rs'
target datalayout = "e-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"
@vtable1267 = internal constant { void (i8*)*, i64, i64, i64 ({}*, i64)* } { void (i8*)* @_ZN2i814glue_drop.126517h59f3793ece30fe9eE, i64 8, i64 8, i64 ({}*, i64)* @"_ZN14_$LP$$RP$.Many6switch20h6ca796108d9da36e9aaE" }
; Function Attrs: nounwind readnone uwtable
diff --git a/lib/Sema/SemaDecl.cpp b/lib/Sema/SemaDecl.cpp
index d7b5ba4..43e7214 100644
--- a/lib/Sema/SemaDecl.cpp
+++ b/lib/Sema/SemaDecl.cpp
@@ -9537,6 +9537,10 @@ static bool ShouldWarnAboutMissingPrototype(const Functio
if (FD->isMain())
return false;
+ if (IdentifierInfo *II = FD->getIdentifier())
+ if (II->isStr("main"))
diff --git a/lib/AST/Decl.cpp b/lib/AST/Decl.cpp
index 101b164..20ba455 100644
--- a/lib/AST/Decl.cpp
+++ b/lib/AST/Decl.cpp
@@ -2271,7 +2271,7 @@ bool FunctionDecl::isMain() const {
const TranslationUnitDecl *tunit =
dyn_cast<TranslationUnitDecl>(getDeclContext()->getRedeclContext());
return tunit &&
- !tunit->getASTContext().getLangOpts().Freestanding &&
+ //!tunit->getASTContext().getLangOpts().Freestanding &&
target triple = "x86_64-unknown-linux-gnu"
@Array2Glob = external global [2500 x i32]
define void @__PascalMain() {
%1 = add i32 undef, 4
br label %P.Proc8.exit
P.Proc8.exit:
%valueindex35.i = getelementptr [2500 x i32]* @Array2Glob, i32 0, i32 %1
; ModuleID = 'llvm-re'
@transitiontable = internal constant [3 x [2 x i32]] [[2 x i32] [i32 1, i32 -1], [2 x i32] [i32 -1, i32 2], [2 x i32] [i32 3, i32 -1]]
define i32 @match(i8*) {
entry:
%Index = alloca i32
store i32 0, i32* %Index
%IsMatch = alloca i32
store i32 0, i32* %IsMatch
diff --git a/lib/Driver/Tools.cpp b/lib/Driver/Tools.cpp
index 52ba489..9ebee04 100644
--- a/lib/Driver/Tools.cpp
+++ b/lib/Driver/Tools.cpp
@@ -1323,7 +1323,9 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,
// Disable the verification pass in -asserts builds.
#ifdef NDEBUG
- CmdArgs.push_back("-disable-llvm-verifier");
+ types::ID MainFileType = Inputs[0].getType();